protected Task WaitForAction(string shardName, ShardAction action, TimeSpan timeout = default) { if (timeout == default) { timeout = 30.Seconds(); } return(new ShardActionWatcher(_daemon.Tracker, shardName, action, timeout).Task); }
public ShardActionWatcher(ShardStateTracker tracker, string shardName, ShardAction expected, TimeSpan timeout) { _shardName = shardName; _expected = expected; _completion = new TaskCompletionSource <ShardState>(); _timeout = new CancellationTokenSource(timeout); _timeout.Token.Register(() => { _completion.TrySetException(new TimeoutException( $"Shard {_shardName} did receive the action {_expected} in the time allowed")); }); _unsubscribe = tracker.Subscribe(this); }
public ShardState(AsyncProjectionShard shard, ShardAction action) : this(shard.Name, 0) { Action = action; }