public async Task ReceiveAsync(IContext context) { switch (context.Message) { case Started _: { _inner = Grains._HelloGrainFactory(); context.SetReceiveTimeout(TimeSpan.FromSeconds(30)); break; } case ReceiveTimeout _: { context.Self.Stop(); break; } case GrainRequest request: { switch (request.Method) { case "SayHello": { var r = HelloRequest.Parser.ParseFrom(request.MessageData); try { var res = await _inner.SayHello(r); var grainResponse = new GrainResponse { MessageData = res.ToByteString(), }; context.Respond(grainResponse); } catch (Exception x) { var grainErrorResponse = new GrainErrorResponse { Err = x.ToString() }; context.Respond(grainErrorResponse); } break; } } break; } } }
public HelloGrainActor(Grains grains) { _grains = grains; }