public void Start(IProjectionTrack track, DaemonLifecycle lifecycle, CancellationToken token = default(CancellationToken)) { _track = track; if (_fetchingTask != null && !_fetchingTask.IsCompleted) { throw new InvalidOperationException("The Fetcher is already started!"); } if (State == FetcherState.Active) return; _token = token; State = FetcherState.Active; if (track.LastEncountered > _lastEncountered) { _lastEncountered = track.LastEncountered; } _logger.FetchStarted(track); _fetchingTask = Task.Run(() => fetchEvents(track, lifecycle), token) .ContinueWith(t => { _logger.FetchingStopped(track); }, token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
public void Start(IProjectionTrack track, DaemonLifecycle lifecycle, CancellationToken token = default(CancellationToken)) { _track = track; if (_fetchingTask != null && !_fetchingTask.IsCompleted) { throw new InvalidOperationException("The Fetcher is already started!"); } if (State == FetcherState.Active) return; _token = token; State = FetcherState.Active; if (track.LastEncountered > _lastEncountered) { _lastEncountered = track.LastEncountered; } _logger.FetchStarted(track); _fetchingTask = Task.Factory.StartNew(async () => { await fetchEvents(track, lifecycle).ConfigureAwait(false); }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default) .ContinueWith(t => { _logger.FetchingStopped(track); }, token); }
public void Start(IProjectionTrack track, DaemonLifecycle lifecycle, CancellationToken token = default(CancellationToken)) { _track = track; if (_fetchingTask != null && !_fetchingTask.IsCompleted) { throw new InvalidOperationException("The Fetcher is already started!"); } if (State == FetcherState.Active) { return; } _token = token; State = FetcherState.Active; if (track.LastEncountered > _lastEncountered) { _lastEncountered = track.LastEncountered; } _logger.FetchStarted(track); _fetchingTask = Task.Run(() => fetchEvents(track, lifecycle), token) .ContinueWith(t => { _logger.FetchingStopped(track); }, token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
public void Start(Type viewType, DaemonLifecycle lifecycle) { if (!_tracks.ContainsKey(viewType)) { throw new ArgumentOutOfRangeException(nameof(viewType)); } _tracks[viewType].Start(lifecycle); }
public void Start(Type viewType, DaemonLifecycle lifecycle) { if (!_tracks.TryGetValue(viewType, out var track)) { throw new ArgumentOutOfRangeException(nameof(viewType)); } findCurrentEventLogPosition(viewType); track.Start(lifecycle); }
public void Start(DaemonLifecycle lifecycle) { _logger.StartingProjection(this, lifecycle); _store.Schema.EnsureStorageExists(_projection.Produces); startConsumers(); Lifecycle = lifecycle; _fetcher.Start(this, lifecycle, _cancellation.Token); }
public void Start(DaemonLifecycle lifecycle) { _logger.StartingProjection(this, lifecycle); EnsureStorageExists(_tenant); startConsumers(); Lifecycle = lifecycle; _fetcher.Start(this, lifecycle, _cancellation.Token); IsRunning = true; }
private async Task fetchEvents(IProjectionTrack track, DaemonLifecycle lifecycle) { while (!_token.IsCancellationRequested && State == FetcherState.Active) { var page = await FetchNextPage(_lastEncountered).ConfigureAwait(false); if (page.ShouldPause()) { if (lifecycle == DaemonLifecycle.Continuous) { State = FetcherState.Waiting; _logger.PausingFetching(track, _lastEncountered); #pragma warning disable 4014 Task.Delay(_settings.FetchingCooldown, _token).ContinueWith(t => { Start(track, lifecycle, _token); }, _token); #pragma warning restore 4014 } else { State = FetcherState.Paused; _logger.FetchingIsAtEndOfEvents(track); track.Finished(page.Ending()); _lastEncountered = page.LastEncountered(); track.QueuePage(page); break; } } _lastEncountered = page.LastEncountered(); track.QueuePage(page); } }
public void Start(IProjectionTrack track, DaemonLifecycle lifecycle, CancellationToken token = default(CancellationToken)) { _track = track; if (_fetchingTask != null && !_fetchingTask.IsCompleted) { throw new InvalidOperationException("The Fetcher is already started!"); } if (State == FetcherState.Active) { return; } _token = token; State = FetcherState.Active; if (track.LastEncountered > _lastEncountered) { _lastEncountered = track.LastEncountered; } _logger.FetchStarted(track); _fetchingTask = Task.Factory.StartNew(async() => { await fetchEvents(track, lifecycle).ConfigureAwait(false); }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default) .ContinueWith(t => { _logger.FetchingStopped(track); }, token); }
public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle) { _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}"); }
/// <inheritdoc cref="IDaemonLogger" /> public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle) { _logger.LogInformation("Starting projection {@Track} running as {Lifecycle}", new { track.LastEncountered, track.IsRunning, track.ViewType }, lifecycle); }
public void Start <T>(DaemonLifecycle lifecycle) { Start(typeof(T), lifecycle); }
public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle) { }
private async Task fetchEvents(IProjectionTrack track, DaemonLifecycle lifecycle) { while (!_token.IsCancellationRequested && State == FetcherState.Active) { var page = await FetchNextPage(_lastEncountered).ConfigureAwait(false); if (page.Count == 0) { if (lifecycle == DaemonLifecycle.Continuous) { State = FetcherState.Waiting; _logger.PausingFetching(track, _lastEncountered); #pragma warning disable 4014 Task.Delay(_settings.FetchingCooldown, _token).ContinueWith(t => { Start(track, lifecycle, _token); }, _token); #pragma warning restore 4014 } else { State = FetcherState.Paused; _logger.FetchingIsAtEndOfEvents(track); track.Finished(_lastEncountered); break; } } else { _lastEncountered = page.To; track.QueuePage(page); } } }
public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle) { Logger.Information("Starting projection {Projection} with lifecycle {Lifecycle}", ToName(track), lifecycle); }