diff --git a/orleans/Chirper/Chirper.Grains/ChirperAccount.cs b/orleans/Chirper/Chirper.Grains/ChirperAccount.cs index 5d72315b932..b58fcc76b5b 100644 --- a/orleans/Chirper/Chirper.Grains/ChirperAccount.cs +++ b/orleans/Chirper/Chirper.Grains/ChirperAccount.cs @@ -3,10 +3,11 @@ using Microsoft.Extensions.Logging; using Orleans.Concurrency; using Orleans.Runtime; +using Orleans.Serialization.Invocation; namespace Chirper.Grains; -[Reentrant] +[MayInterleave(nameof(WontFollowAndUnfollowSimultaneously))] public sealed class ChirperAccount : Grain, IChirperAccount { /// @@ -48,6 +49,9 @@ public ChirperAccount( private static string GrainType => nameof(ChirperAccount); private string GrainKey => this.GetPrimaryKeyString(); + public static bool WontFollowAndUnfollowSimultaneously(IInvokable request) => + request.GetMethodName() is not (nameof(FollowUserIdAsync) or nameof(UnfollowUserIdAsync)); + public override Task OnActivateAsync(CancellationToken _) { _logger.LogInformation("{GrainType} {GrainKey} activated.", GrainType, GrainKey);