public async Task Pause(TimeSpan timeout) { await Stop(); Status = AgentStatus.Paused; _tracker.Publish(new ShardState(_projectionShard, ShardAction.Paused)); #pragma warning disable 4014 // ReSharper disable once MethodSupportsCancellation Task.Run(async () => #pragma warning restore 4014 { // ReSharper disable once MethodSupportsCancellation await Task.Delay(timeout); _cancellationSource = new CancellationTokenSource(); _cancellation = _cancellationSource.Token; var parameters = new ActionParameters(this, async () => { try { await Start(_daemon); } catch (Exception e) { throw new ShardStartException(_projectionShard.Name, e); } }); parameters.LogAction = (l, e) => { l.LogError(e, "Error trying to start shard '{ShardName}' after pausing", _projectionShard.Name); }; await _daemon.TryAction(parameters); }); }
private async Task<EventRange> loadEvents(EventRange range) { var parameters = new ActionParameters(this, async () => { await _fetcher.Load(_projectionShard.Name, range, _cancellation); if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Loaded events for {Range}", range); } }) { LogAction = (logger, e) => { logger.LogError(e, "Error loading events for {Range}", range); } }; await _daemon.TryAction(parameters); return range; }
private async Task <EventRange> loadEvents(EventRange range) { var parameters = new ActionParameters(this, async() => { await _fetcher.Load(range, _cancellation).ConfigureAwait(false); if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Loaded events {Range} for {ProjectionShardIdentity}", range, ProjectionShardIdentity); } }) { LogAction = (logger, e) => { logger.LogError(e, "Error loading events {Range} for {ProjectionShardIdentity}", range, ProjectionShardIdentity); } }; await _daemon.TryAction(parameters).ConfigureAwait(false); return(range); }