Comments (4)
Cool, I'll get to work on the receive pipeline first, then continue with persistence.
from protoactor-dotnet.
Given a receive pipeline like that which exists in Go right now, adding persistence without inheritance shouldn't be too difficult.
The main problem that I see is to find a suitable replacement for the mixin/embedded field. One option is to replace it with an interface that you need to implement, containing the ProviderState, EventIndex, etc. The downside of it is that the implementation of those properties will be forced upon each actor implementation. One way of making it a bit easier on the actor implementer is to wrap all of the embedded fields in a composed type.
So you would have something like the below (based on existing persistence example). It is basically equivalent to the Go implementation except you need to "dot in" to access the persistence stuff, and the Actor needs to implement an auto-property from the interface. Thoughts?
// user code
class MyPersistentActor : IActor, IPersistentActor
{
public PersistenceState PersistenceState { get; set; }
public Task ReceiveAsync(IContext context)
{
switch (context.Message)
{
case RenameCommand rename:
PersistenceState.PersistReceive(rename);
break;
case AddItemCommand addItem:
PersistenceState.PersistReceive(addItem);
break;
}
}
}
// protoactor implementation
public interface IPersistentActor
{
PersistenceState PersistenceState { get; set; }
}
public class PersistenceState
{
public ProviderState ProviderState { get; set; }
public int EventIndex { get; set; }
public IContext Context { get; set; }
public bool Recovering { get; set; }
public void Init(PersistenceProvider provider, IContext context)
{
ProviderState = provider.GetState();
Context = context;
Recovering = true;
//... more init code
}
}
Receive Using(PersistenceProvider provider)
{
return context =>
{
switch (context.Message)
{
case Started started:
break;
case Replay replay:
var p = context.Actor as IPersistentActor;
if (p != null)
{
p.PersistenceState = new PersistenceState();
p.PersistenceState.Init(provider, context);
}
break;
}
};
}
from protoactor-dotnet.
Love it, your interface suggestion is as good as it gets in C# IMO.
I cant see any other non magic way of doing this with less code.
from protoactor-dotnet.
This has been merged, closing
from protoactor-dotnet.
Related Issues (20)
- Don't list blocked nodes unknown to self HOT 1
- Large cluster stability notes: HOT 2
- Gossip actor jam HOT 1
- Introduce IsStopping flag
- What is the difference between EventStream and pub-sub? HOT 2
- Remote blocking and Cluster MemberList HOT 2
- At-most-once guarantee is broken HOT 2
- Debugging documentation HOT 3
- Mocking grain client and testability HOT 2
- Is it possible for PubSub to lose messages without subscriber knowing?
- Kubernetes Provider on pod hostNetwork enabled HOT 1
- Amazon ECS cluster provider fails with AWS error
- SeedNode provider conceptually broken HOT 5
- RequestAsync method doesn't work in client mode
- ETCD provider HOT 6
- Introduce message priority for Remote layer HOT 2
- Dedicated thread dispatcher for some system actors
- 1.5.0 cluster seems broken? HOT 1
- SeedNodeClusterProvider: Consensus not reached, Initiating rebalance [1.5.0] HOT 2
- ProtoGenTask fails when UseArtifactsOutput = true is active
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoactor-dotnet.