예제 #1
0
 public void FetchingStopped(IProjectionTrack track)
 {
     if (Logger.IsEnabled(LogEventLevel.Verbose))
     {
         Logger.Verbose("Fetching stopped for projection {Projection}", ToName(track));
     }
 }
예제 #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));
     }
 }
예제 #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));
     }
 }
예제 #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);
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #7
0
파일: Fetcher.cs 프로젝트: ifle/marten
        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);
        }
예제 #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);
     }
 }
예제 #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));
     }
 }
예제 #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);
     }
 }
예제 #11
0
파일: Fetcher.cs 프로젝트: phinett/marten
        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);
            }
        }
예제 #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);
        }
예제 #13
0
 public string ToName(IProjectionTrack track) => track.ViewType.Name;
예제 #14
0
 public void Stopping(IProjectionTrack track)
 {
     Logger.Information("Stopping projection {Projection}", ToName(track));
 }
예제 #15
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Fetching finished for {track.ViewType.FullName} at event {lastEncountered}");
 }
예제 #16
0
 public void Stopped(IProjectionTrack track)
 {
     
 }
예제 #17
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     
 }
예제 #18
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     
 }
예제 #19
0
 public void ClearingExistingState(IProjectionTrack track)
 {
 }
예제 #20
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
 }
예제 #21
0
 public void Stopped(IProjectionTrack track)
 {
 }
예제 #22
0
 public void Stopping(IProjectionTrack track)
 {
 }
예제 #23
0
 public void FetchingStopped(IProjectionTrack track)
 {
     _writeline($"Stopped event fetching for {track.ViewType.FullName}");
 }
예제 #24
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
예제 #25
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     _writeline($"Clearing the existing state for projection {track.ViewType.FullName}");
 }
예제 #26
0
 public void Stopped(IProjectionTrack track)
 {
     _writeline($"Stopped projection {track.ViewType.FullName}");
 }
예제 #27
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     
 }
예제 #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}");
 }
예제 #29
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     
 }
예제 #30
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     _writeline($"Clearing the existing state for projection {track.ViewType.FullName}");
 }
예제 #31
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     
 }
예제 #32
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
     _writeline($"Projection {track.ViewType.FullName} is starting > {track.LastEncountered}");
 }
예제 #33
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     Logger.Information("Starting projection {Projection} with lifecycle {Lifecycle}", ToName(track), lifecycle);
 }
예제 #34
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Pausing fetching for {track.ViewType.FullName}, last encountered {lastEncountered}");
 }
예제 #35
0
 public void Stopped(IProjectionTrack track)
 {
     Logger.Information("Projection {Projection} stopped", ToName(track));
 }
예제 #36
0
 public void FetchStarted(IProjectionTrack track)
 {
     _writeline($"Starting fetching for {track.ViewType.FullName}");
 }
예제 #37
0
 public void ClearingExistingState(IProjectionTrack track)
 {
     Logger.Information("Clearing existing state for projection {Projection}", ToName(track));
 }
예제 #38
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     _writeline($"Fetching is at the end of the event log for {track.ViewType.FullName}");
 }
예제 #39
0
 public void FetchingStopped(IProjectionTrack track)
 {
     _writeline($"Stopped event fetching for {track.ViewType.FullName}");
 }
예제 #40
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     _writeline($"{page} executed for {track.ViewType.FullName}");
 }
예제 #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);
                }
            }
        }
예제 #42
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Fetching finished for {track.ViewType.FullName} at event {lastEncountered}");
 }
예제 #43
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
 }
예제 #44
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
예제 #45
0
 public void FetchStarted(IProjectionTrack track)
 {
     
 }
예제 #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}");
 }
예제 #47
0
 public void FetchingStopped(IProjectionTrack track)
 {
     
 }
예제 #48
0
 public void FetchingIsAtEndOfEvents(IProjectionTrack track)
 {
     _writeline($"Fetching is at the end of the event log for {track.ViewType.FullName}");
 }
예제 #49
0
 public void FetchingFinished(IProjectionTrack track, long lastEncountered)
 {
     
 }
예제 #50
0
 public void FetchStarted(IProjectionTrack track)
 {
     _writeline($"Starting fetching for {track.ViewType.FullName}");
 }
예제 #51
0
 public void Stopping(IProjectionTrack track)
 {
     
 }
예제 #52
0
 public void PausingFetching(IProjectionTrack track, long lastEncountered)
 {
     _writeline($"Pausing fetching for {track.ViewType.FullName}, last encountered {lastEncountered}");
 }
예제 #53
0
 public void ProjectionBackedUp(IProjectionTrack track, int cachedEventCount, EventPage page)
 {
     
 }
예제 #54
0
 public void DeterminedStartingPosition(IProjectionTrack track)
 {
     _writeline($"Projection {track.ViewType.FullName} is starting > {track.LastEncountered}");
 }
예제 #55
0
 public void Stopped(IProjectionTrack track)
 {
     _writeline($"Stopped projection {track.ViewType.FullName}");
 }
예제 #56
0
 public void PageExecuted(EventPage page, IProjectionTrack track)
 {
     _writeline($"{page} executed for {track.ViewType.FullName}");
 }