petabridge / akka.persistence.extras Goto Github PK
View Code? Open in Web Editor NEWAkka.NET Persistence extras and ideas
Home Page: https://devops.petabridge.com/
License: Apache License 2.0
Akka.NET Persistence extras and ideas
Home Page: https://devops.petabridge.com/
License: Apache License 2.0
Similar to what we do today for IPersistentRepresentation
et al.
Major changes needed:
ImmutableDictionary<T>
in favor of Dictionary<T>
- if the semantic isn't accessed concurrently, then it's not needed.UnconfirmedDelivery
messages to the AtLeastOnceDelivery
state incrementally, so these items can be retrieved via Recover<UnconfirmedDelivery>
.Need to add an Akka.Persistence.IMessage
type for a confirmed delivery which can be recovered during replay.
Apparently Akka.Persistence.Exras needs to be rebuilt with new Akka libraries. Running them with Akka.NET 1.5 causes the following error:
Method not found: 'Void Akka.Event.ILoggingAdapter.Error(System.String, System.Object[])'.
at Akka.Persistence.Extras.PersistenceSupervisor.OnTerminated(Object message)
at Akka.Persistence.Extras.PersistenceSupervisor.Receive(Object message)
at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
at Akka.Actor.ActorCell.ReceiveMessage(Object message)
at Akka.Actor.ActorCell.Invoke(Envelope envelope)
This is a showstopper for upgrading to Akka.NET 1.5 for those using PersistenceSupervisor.
This is an outline for an "Akka.Persistence.TestKit" NuGet package that can be used by Akka.NET developers to help test for possible errors that may come up in the course of using Akka.Persistence, such as:
These fake journal and snapshot store implementations should be programmable, so if we take a typical Arrange-Act-Assert pattern and factor our "FailingJournal" or "FailingSnapshotStore" into it:
public class MyTestKitClass : Akka.TestKit.Xunit2.Testkit{
private readonly FailingJournal _failingJournal
public MyTestKitClass()
: base(FailingJournal.DefaultConfig()) // need FailingJournal HOCON
{
// need to grab an instance of the FailingJournal for programming purposes
_failingJournal = PersistenceExt.Get(Sys);
}
public async Task MyFakeUnitTest(){
// arrange
var myPersistentActor = Sys.ActorOf(Props.Create(() => new MyPersistActor()), "p");
myPersistentActor.Tell("write"); // write one message to journal while it's still working
ExpectMsg("ack"); // message gets processed
// terminate actor
await myPersistentActor.GracefulStop();
// act
await _failingJournal.BeginFailingWrites(); // simulate journal network disconnect
// assert
// re-create a persistent actor - should fail
EventFilter.Exception<RecoveryException>().ExpectOne(() => {
var myPersistentActor2 = Sys.ActorOf(Props.Create(() => new MyPersistActor()), "p");
// actor should stop as a result of recovery failure
Watch(myPersistentActor);
ExpectTerminated(myPersistentActor);
});
}
}
That's the general idea - make it easy to progam the behavior the journal and shapshot store in Akka.Persistence prior to actually using it.
To make it easier to understand the requirements going forward, here are some technical terms we're going to use throuhout this document:
FailingJournal
- this is the journal that can be programmed to fail altogether or reject persistent messages.FailingSnapshotStore
- same idea as the FailingJournal
, but for the SnapshotStore
.SnapshotWriteFailure
message.The Akka.Persistence.TestKit package might eventually be released as an official part of Akka.NET, but for the time being, let's release the package as part of Akka.Persistence.Extras so we can avoid the inertia ivolved in making a new Akka.NET release as we're trying to get Akka.NET v1.4.0 shipped right now.
For the time being then, this package should be shipped as Akka.Persistence.Extras.TestKit
.
This project should be built against Akka.Persistence v1.3.13.
FailingJournal
and FailingSnapshotStore
APIsThe FailingJournal
and FailingSnapshotStore
classes APIs must enable the end-user to do the following:
Task
, by the time that Task
completes the toggle operation must have completed.Task
, by the time that Task
completes the toggle operation must have completed.Task
, by the time that Task
completes the predicate must be securely in-place.Task
, by the time that Task
completes the toggle operation must have completed.FailingJournal
and FailingSnapshotStore
inside an Akka.NET TestKit TestThe FailingJournal
and the FailingSnapshotStore
should wrap around the underlying MemoryJournal
and MemorySnapshotStore
and use them for underlying storage.
But in order to activate either one of these components inside a TestKit
test, the end-user must pass in the embedded HOCON built into the FailingJournal.DefaultConfig()
or FailingSnapshotStore.DefaultConfig()
methods into the TestKit
base class constructor, like this:
public class MyTestKitClass : Akka.TestKit.Xunit2.Testkit{
private readonly FailingJournal _failingJournal
public MyTestKitClass()
: base(FailingJournal.DefaultConfig()) // need FailingJournal HOCON
{
// need to grab an instance of the FailingJournal for programming purposes
_failingJournal = PersistenceExt.Get(Sys);
}
// tests
}
Need to cover all functional requirements with unit tests, in order to make sure that the API requirements are all met by the implementation. Expand as needed along with the API surface area.
If my persistent events all implement IConfirmable
, maybe I don't need to specify a "make confirmable" delegate.
麻烦把国瑞的代码删除掉,谢谢
Allow the PersistenceSupervisor to pass itself into the childProps
dynamically via invoking a function rather than hard-coding the props of the child - that way we don't have to rely on hard-coding the underlying PersistentActor
to send confirmation messages back to its parent via Context.Parent.Tell
, which seems brittle.
We should explain the motivation behind why the DeDuplicatingReceiveActor
needs to persist its state in the first place.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.