asynkron / protoactor-go

Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
http://proto.actor
Apache License 2.0
5.03k stars 523 forks source link

How to do grain reentrance #980

Closed qazwsxedckll closed 8 months ago

qazwsxedckll commented 9 months ago

Request -> GrainA -> GrainB -> GrainA.

I find something like ctx.RequestFuture and ctx.ReenterAfter but I do not know how to do it in a cluster.

Based on my understanding, I can either write my own type ContextProducer func(*Cluster) Context which turns every request reenterable or I have to add a method to type Context interface

I found https://github.com/asynkron/protoactor-dotnet/pull/913 but I cannot understand what is happening.

rogeralsing commented 9 months ago

In .NET, there are two methods generated, one which is more actor low level and can deal with reentrancy. the default impl of this method just calls the RPC version.

In the case where someone wants to use reentrancy, they can then override the low level method and handle it in there. For Go, we need a different approach as we don´t have overrides in the same sense as in OOP

qazwsxedckll commented 9 months ago

Sorry but can you be a little more specific.

Do you mean two methods generated in public class {{Name}}Client? The one without ISenderContext is more low level? I cannot find any implementation of RequestAsync<object>(_id, {{../Name}}Actor.Kind, gr, ct); in Proto.Cluster.Cluster, only one with ISenderContext.

Or do you mean the vitural method public virtual async Task {{Name}}({{LeadingParameterDefinition}}Action{{#if UseReturn}}<{{OutputName}}>{{/if}} respond, Action<string> onError) which is meant to be overridden to handle reentrancy.