-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for UnrestrictedStash
#6325
Conversation
[Obsolete("Bounded stashing is not yet implemented. Unbounded stashing will be used instead [0.7.0]")] | ||
public interface IWithBoundedStash : IActorStash, IRequiresMessageQueue<IBoundedDequeBasedMessageQueueSemantics> | ||
[Obsolete("Use `IWithStash` with a configured BoundedDeque-based mailbox instead.")] | ||
public interface IWithBoundedStash : IWithUnrestrictedStash, IRequiresMessageQueue<IBoundedDequeBasedMessageQueueSemantics> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this type since typically you'd want to change the mailbox or stash capacity with a bounded deque, which cannot be done programmatically (AFAIK)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this type in v1.5 in a separate PR - I'd like to backport this as-is to v1.4 first.
} | ||
|
||
if (actorType.Implements<IWithUnrestrictedStash>()) | ||
return new UnrestrictedStashImpl(context); | ||
|
||
throw new ArgumentException($"Actor {actorType} implements an unrecognized subclass of {typeof(IActorStash)} - cannot instantiate", nameof(actorType)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BoundedStashImpl
, UnboundedStashImpl
and UnrestrictedStashImpl
are all empty implementations, so we could get away with a single type (i.e., StashSupportImpl
) like in the JVM.
So in practice, how does this work? The user has to manually specify a mailbox type in addition to specifying the stash type? |
Correct. By using |
971318e
to
57d9f60
Compare
Updated the documentation. As an addendum to my previous comment, you now have two main stash interfaces to work with:
The |
57d9f60
to
bd276df
Compare
@Aaronontheweb could we backport this and #6323 to |
6ddfbf0
to
486c5f6
Compare
486c5f6
to
c6cc684
Compare
c6cc684
to
92e1e16
Compare
Unrelated tests failing |
I put it on my planner to review this today - will do @ismaelhamed |
yep, I don't see why not provided that there's nothing high risk in the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
Here is an example of the `IWithUnboundedStash` interface in action: | ||
> [!NOTE] | ||
> The interface `IWithStash` implements the marker interface `IRequiresMessageQueue<IDequeBasedMessageQueueSemantics>` which requests the system to automatically choose a deque-based mailbox implementation for the actor (defaults to an unbounded deque mailbox). If you want more control over the mailbox, see the documentation on mailboxes: [Mailboxes](xref:mailboxes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The result of this is that when an actor is restarted, any stashed messages will be delivered to the new incarnation of the actor. This is usually the desired behavior. | ||
|
||
> [!NOTE] | ||
> If you want to enforce that your actor can only work with an unbounded stash, then you should use the `IWithUnboundedStash` interface instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
public interface IWithTimers | ||
{ | ||
Akka.Actor.ITimerScheduler Timers { get; set; } | ||
} | ||
public interface IWithUnboundedStash : Akka.Actor.IActorStash, Akka.Dispatch.IRequiresMessageQueue<Akka.Dispatch.IUnboundedDequeBasedMessageQueueSemantics> { } | ||
public interface IWithUnboundedStash : Akka.Actor.IActorStash, Akka.Actor.IWithUnrestrictedStash, Akka.Dispatch.IRequiresMessageQueue<Akka.Dispatch.IUnboundedDequeBasedMessageQueueSemantics> { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is extend-only, so it's safe.
@@ -272,7 +272,7 @@ namespace Akka.Persistence.Sql.Common.Journal | |||
public long Offset { get; } | |||
public Akka.Actor.IActorRef ReplyTo { get; } | |||
} | |||
public abstract class SqlJournal : Akka.Persistence.Journal.AsyncWriteJournal, Akka.Actor.IActorStash, Akka.Actor.IWithUnboundedStash, Akka.Dispatch.IRequiresMessageQueue<Akka.Dispatch.IUnboundedDequeBasedMessageQueueSemantics> | |||
public abstract class SqlJournal : Akka.Persistence.Journal.AsyncWriteJournal, Akka.Actor.IActorStash, Akka.Actor.IWithUnboundedStash, Akka.Actor.IWithUnrestrictedStash, Akka.Dispatch.IRequiresMessageQueue<Akka.Dispatch.IUnboundedDequeBasedMessageQueueSemantics> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think that we might have to update all of the Akka.Persistence plugins, since the journal currently uses an unbounded stash. I don't think that should be important unless there's something on the normal IWithUnrestrictedStash
interface that could cause a MissingMethodException
but it looks to me like there isn't any. Just wanted to make note of this in case I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really because the journal is still implementing IWithUnboundedStash
which is more constrained. So, the mailbox is going to be selected based on it and not IWithUnrestrictedStash
.
[Obsolete("Bounded stashing is not yet implemented. Unbounded stashing will be used instead [0.7.0]")] | ||
public interface IWithBoundedStash : IActorStash, IRequiresMessageQueue<IBoundedDequeBasedMessageQueueSemantics> | ||
[Obsolete("Use `IWithStash` with a configured BoundedDeque-based mailbox instead.")] | ||
public interface IWithBoundedStash : IWithUnrestrictedStash, IRequiresMessageQueue<IBoundedDequeBasedMessageQueueSemantics> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this type in v1.5 in a separate PR - I'd like to backport this as-is to v1.4 first.
Currently, once you've marked your actor with any of the Stash interfaces (
IWithUnboundedStash
orIWithBoundedStash
) there's no way to change it afterward via configuration (it is a design-time operation that requires recompiling).But there are two traits that allow users to do that in the JVM:
A default
Stash
trait (IWithStash
in this PR) which allows using any Deque-based mailbox (i.e., bounded or unbounded) via configuration. By default, it uses an UnboundedDeque mailbox, so it is akin to the currentIWithUnboundedStash
if you don't specify a custom mailbox type.UnrestrictedStash
trait, which does not enforce any mailbox type. The proper mailbox must be configuredmanually.
Checklist