コード例 #1
0
ファイル: DaemonContext.cs プロジェクト: tonykaralis/marten
        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);
        }
コード例 #2
0
ファイル: DaemonContext.cs プロジェクト: tonykaralis/marten
        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);
        }
コード例 #3
0
 public ShardState(AsyncProjectionShard shard, ShardAction action) : this(shard.Name, 0)
 {
     Action = action;
 }