示例#1
0
 /// <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
         }));
     }
 }
示例#2
0
        public Task <StateMachineCommandResponse> ApplyCommandAsync(StateMachineCommandRequest command)
        {
            var nodes = _nodes.Values.ToArray();
            var node  = nodes[_r.Next(0, nodes.Length)];

            return(node.ApplyCommandAsync(command));
        }
示例#3
0
 public Task <StateMachineCommandResponse> ApplyCommandAsync(StateMachineCommandRequest command)
 {
     throw new NotImplementedException();
 }