Introducing Kameo-persistence #210
cwahn
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I am happy to introduce kameo-persistence, a persistence add-on for Kameo.
Motivation
For production-level application, it is necessary to remember some data and configuration on persistent storage, so that it could provide continuous user experience.
Of course this could be done in many other way, but I found it is quite repetitive and tedious task to do.
Solution
The solution I figured out is that make
PersistentActortrait and assign unique "persistence key" (which is file URL at the moment) to instance, and let user could save "snapshot" at discretion.The "Snapshot" type is something
Serialize,Deserializeto be saved and restored.From<&Self: Actor>andInto<Self::Args>to capture snapshot fromActorand respawnActorwith Args.By default it could be derivable with minimal manual implementation.
However for some manager-like actors holding dynamically created actor, I find useful to make
Argstype following theActortype, but substitutingActorRefas URL so that sub actor could be spawned byon_startmethod.Currently it suppose "persistence key" indicate directory-like path, not file-path, so that it could save it's intrinsic data, in "index file", while providing sub directory to conceptually owned sub actors so that they could save captures at their own phase. But this could be changed in future.
Todo
Note
Since this is very early draft, their would be plenty of issue.
Please feel free to leave comment so that it could serve your needs.
All reactions