Open
Conversation
Member
|
@kmruiz we are breaking backwards compatibility with this, right? |
Member
Author
|
We are if we decide that all materialisers must implement the two new functions. However, we could decide to make them optional and maintain compatibility with older versions. I agree however having a call and discuss next steps |
Member
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reason / Issue that solves
Right now there is no easy way to free resources of an actor when it's not useful anymore. Releasing actors should allow systems to clean up resources and dematerialise on the given persistence mechanism, if any.
How does it work?
An actor is released by calling the parent actor system with a reference to the actor to release.
system.releaseActor(clock)The Release Message message will be sent to the actor mailbox, to be processed. This guarantees that all received messages before the release message are processed in order.
Once the message is consumed by the actor, materialisers are notified on
onBeforeRelease, so they can prepare any clean up, if necessary.Once all materialisers are notified (async), the actor system unsubscribes the actor from all mailboxes and topics. Then, the actor notifies for one last time the materialisers on
onAfterRelease. For example, if we store the information in the browser local storage or on a database,onAfterReleasewould be a good entrypoint to clean up resources.Released actors that receive messages will discard the message and throw an exception. The exception contains a field isActorReleased that should be true if the cause is the release of an actor. Also contains a getMessage method with a human-readable explanation.
Breaking Changes
Two new methods in the materialisers that are mandatory: