/// <inheritdoc /> public Task <StateMachineCommandResponse> ApplyCommandAsync(StateMachineCommandRequest command) { if (Role == Role.Leader) { _commands.TryAdd(command); return(Task.FromResult(new StateMachineCommandResponse() { Outcome = CommandOutcome.Accepted })); } else if (_settings.ExecuteStateMachineCommandsOnClientBehalf && _leaderAddress != null) { var leaderProxy = _peerManager.GetProxy(_leaderAddress); return(leaderProxy.ApplyCommandAsync(command)); } else if (_settings.RedirectStateMachineCommands && _leaderAddress != null) { return(Task.FromResult(new StateMachineCommandResponse() { Outcome = CommandOutcome.Redirect, DirectTo = _leaderAddress })); } else { return(Task.FromResult(new StateMachineCommandResponse() { Outcome = CommandOutcome.ServiceUnavailable })); } }
public Task <StateMachineCommandResponse> ApplyCommandAsync(StateMachineCommandRequest command) { var nodes = _nodes.Values.ToArray(); var node = nodes[_r.Next(0, nodes.Length)]; return(node.ApplyCommandAsync(command)); }
public Task <StateMachineCommandResponse> ApplyCommandAsync(StateMachineCommandRequest command) { throw new NotImplementedException(); }