public async Task <ActionResult> SendSleepPoison(int worker)
        {
            var cmd  = new BroadcastPoison();
            var res1 = await _clusterClient.RequestAsync <PoisonResponse>("/", GetKind(worker), cmd);

            return(Ok());
        }
        public Task HandleBroadcastPoison(IContext context, BroadcastPoison cmd)
        {
            logger.LogInformation($"PoisonGrain.HandleBroadcastPoison");

            try
            {
                context.Respond(new PoisonResponse());
                return(Task.CompletedTask);
            }
            catch (Exception e)
            {
                this.logger.LogError(e, "Failed in PoisonGrain");
                context.Respond(new PoisonResponse());
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        public override async Task ReceiveAsync(IContext context)
        {
            Task task = context.Message switch
            {
                BroadcastPoison cmd => HandleBroadcastPoison(context, cmd),
                RestartPoison cmd => HandleRestartPoison(context, cmd),
                Started _ => Started(context),
                _ => base.ReceiveAsync(context)
            };

            try
            {
                await task;
            }
            catch (Exception e)
            {
                this.logger.LogError(e, "Failed PoisonGrain");
                context.Respond(new DeadLetterResponse
                {
                    Target = context.Self
                });
            }
        }