Beispiel #1
0
 public void FetchingStopped(IProjectionTrack track)
 {
     if (Logger.IsEnabled(LogEventLevel.Verbose))
     {
         Logger.Verbose("Fetching stopped for projection {Projection}", ToName(track));
     }
 }
Beispiel #2
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     if (Logger.IsEnabled(LogEventLevel.Verbose))
     {
         Logger.Verbose("Fetching is at the end of events for projection {Projection}", ToName(track));
     }
 }
Beispiel #3
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     if (Logger.IsEnabled(LogEventLevel.Debug))
     {
         Logger.Debug("Page {Page} executed for projection {Projection}", ToPageSummary(page), ToName(track));
     }
 }
Beispiel #4
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     if (Logger.IsEnabled(LogEventLevel.Verbose))
     {
         Logger.Verbose("Fetching finished for projection {Projection} at last encountered {LastEncountered}", ToName(track), lastEncountered);
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     if (Logger.IsEnabled(LogEventLevel.Verbose))
     {
         Logger.Verbose("Pausing fetching for projection {Projection}, last encountered {LastEncountered}",
                        ToName(track), lastEncountered);
     }
 }
Beispiel #9
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
     if (Logger.IsEnabled(LogEventLevel.Debug))
     {
         Logger.Debug("Projection {Projection} is backed up with {CachedEventCount}, last page fetched {Page}",
                      ToName(track), cachedEventCount, ToPageSummary(page));
     }
 }
Beispiel #10
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
     if (Logger.IsEnabled(LogEventLevel.Debug))
     {
         Logger.Debug("Determined starting position for projection {Projection} is {Position}",
                      ToName(track),
                      track.LastEncountered);
     }
 }
Beispiel #11
0
        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);
            }
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 public string ToName(IProjectionTrack track) => track.ViewType.Name;
Beispiel #14
0
 public void Stopping(IProjectionTrack track)
 {
     Logger.Information("Stopping projection {Projection}", ToName(track));
 }
Beispiel #15
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Fetching finished for {track.ViewType.FullName} at event {lastEncountered}");
 }
 public void Stopped(IProjectionTrack track)
 {
     
 }
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     
 }
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     
 }
Beispiel #19
0
 public void ClearingExistingState(IProjectionTrack track)
 {
 }
Beispiel #20
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
 }
Beispiel #21
0
 public void Stopped(IProjectionTrack track)
 {
 }
Beispiel #22
0
 public void Stopping(IProjectionTrack track)
 {
 }
Beispiel #23
0
 public void FetchingStopped(IProjectionTrack track)
 {
     _writeline($"Stopped event fetching for {track.ViewType.FullName}");
 }
Beispiel #24
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
Beispiel #25
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     _writeline($"Clearing the existing state for projection {track.ViewType.FullName}");
 }
Beispiel #26
0
 public void Stopped(IProjectionTrack track)
 {
     _writeline($"Stopped projection {track.ViewType.FullName}");
 }
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     
 }
Beispiel #28
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
     _writeline($"Projection {track.ViewType.FullName} is backed up with {cachedEventCount} events in memory, last page fetched was {page}");
 }
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     
 }
Beispiel #30
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     _writeline($"Clearing the existing state for projection {track.ViewType.FullName}");
 }
 public void ClearingExistingState(IProjectionTrack track)
 {
     
 }
Beispiel #32
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
     _writeline($"Projection {track.ViewType.FullName} is starting > {track.LastEncountered}");
 }
Beispiel #33
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     Logger.Information("Starting projection {Projection} with lifecycle {Lifecycle}", ToName(track), lifecycle);
 }
Beispiel #34
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Pausing fetching for {track.ViewType.FullName}, last encountered {lastEncountered}");
 }
Beispiel #35
0
 public void Stopped(IProjectionTrack track)
 {
     Logger.Information("Projection {Projection} stopped", ToName(track));
 }
Beispiel #36
0
 public void FetchStarted(IProjectionTrack track)
 {
     _writeline($"Starting fetching for {track.ViewType.FullName}");
 }
Beispiel #37
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     Logger.Information("Clearing existing state for projection {Projection}", ToName(track));
 }
Beispiel #38
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     _writeline($"Fetching is at the end of the event log for {track.ViewType.FullName}");
 }
Beispiel #39
0
 public void FetchingStopped(IProjectionTrack track)
 {
     _writeline($"Stopped event fetching for {track.ViewType.FullName}");
 }
Beispiel #40
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     _writeline($"{page} executed for {track.ViewType.FullName}");
 }
Beispiel #41
0
        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);
                }
            }
        }
Beispiel #42
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Fetching finished for {track.ViewType.FullName} at event {lastEncountered}");
 }
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
 }
Beispiel #44
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
 public void FetchStarted(IProjectionTrack track)
 {
     
 }
Beispiel #46
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
     _writeline($"Projection {track.ViewType.FullName} is backed up with {cachedEventCount} events in memory, last page fetched was {page}");
 }
 public void FetchingStopped(IProjectionTrack track)
 {
     
 }
Beispiel #48
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     _writeline($"Fetching is at the end of the event log for {track.ViewType.FullName}");
 }
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     
 }
Beispiel #50
0
 public void FetchStarted(IProjectionTrack track)
 {
     _writeline($"Starting fetching for {track.ViewType.FullName}");
 }
 public void Stopping(IProjectionTrack track)
 {
     
 }
Beispiel #52
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Pausing fetching for {track.ViewType.FullName}, last encountered {lastEncountered}");
 }
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
     
 }
Beispiel #54
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
     _writeline($"Projection {track.ViewType.FullName} is starting > {track.LastEncountered}");
 }
Beispiel #55
0
 public void Stopped(IProjectionTrack track)
 {
     _writeline($"Stopped projection {track.ViewType.FullName}");
 }
Beispiel #56
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     _writeline($"{page} executed for {track.ViewType.FullName}");
 }