public override async Task ReceiveAsync(IContext context) { Task task = context.Message switch { PingCmd cmd => HandlePing(context, cmd), ExceptionPoison cmd => HandleExceptionPoison(context, cmd), NoAnswerPoison cmd => HandleNoAnswerPoison(context, cmd), SleepPoison cmd => HandleSleepPoison(context, cmd), Started _ => Started(context), _ => base.ReceiveAsync(context) }; try { await task; } catch (Exception e) { this.logger.LogError(e, "Failed PingGrain"); context.Respond(new DeadLetterResponse { Target = context.Self }); } }
public Task HandleNoAnswerPoison(IContext context, NoAnswerPoison cmd) { logger.LogInformation($"PingGrain.HandleNoAnswerPoison"); try { this.noAnswerCounter++; context.Respond(new PoisonResponse()); return(Task.CompletedTask); } catch (Exception e) { this.logger.LogError(e, "Failed in HandleNoAnswerPoison"); context.Respond(new PingResponse()); } return(Task.CompletedTask); }