コード例 #1
0
ファイル: Fetcher.cs プロジェクト: phillip-haydon/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);
        }
コード例 #2
0
ファイル: Fetcher.cs プロジェクト: danielmarbach/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.Factory.StartNew(async () =>
                {
                    await fetchEvents(track, lifecycle).ConfigureAwait(false);
                },
                    token, TaskCreationOptions.LongRunning, TaskScheduler.Default)
                    .ContinueWith(t =>
                    {
                        _logger.FetchingStopped(track);
                    }, token);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: Daemon.cs プロジェクト: jmbledsoe/marten
        public void Start(Type viewType, DaemonLifecycle lifecycle)
        {
            if (!_tracks.ContainsKey(viewType))
            {
                throw new ArgumentOutOfRangeException(nameof(viewType));
            }

            _tracks[viewType].Start(lifecycle);
        }
コード例 #5
0
        public void Start(Type viewType, DaemonLifecycle lifecycle)
        {
            if (!_tracks.TryGetValue(viewType, out var track))
            {
                throw new ArgumentOutOfRangeException(nameof(viewType));
            }

            findCurrentEventLogPosition(viewType);

            track.Start(lifecycle);
        }
コード例 #6
0
ファイル: ProjectionTrack.cs プロジェクト: ifle/marten
        public void Start(DaemonLifecycle lifecycle)
        {
            _logger.StartingProjection(this, lifecycle);

            _store.Schema.EnsureStorageExists(_projection.Produces);

            startConsumers();

            Lifecycle = lifecycle;
            _fetcher.Start(this, lifecycle, _cancellation.Token);
        }
コード例 #7
0
ファイル: ProjectionTrack.cs プロジェクト: yovannyr/marten
        public void Start(DaemonLifecycle lifecycle)
        {
            _logger.StartingProjection(this, lifecycle);

            EnsureStorageExists(_tenant);

            startConsumers();

            Lifecycle = lifecycle;
            _fetcher.Start(this, lifecycle, _cancellation.Token);

            IsRunning = true;
        }
コード例 #8
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);
            }
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: TracingLogger.cs プロジェクト: danielmarbach/marten
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
 public void Start <T>(DaemonLifecycle lifecycle)
 {
     Start(typeof(T), lifecycle);
 }
コード例 #13
0
ファイル: ProjectionTrack.cs プロジェクト: tim-cools/Marten
        public void Start(DaemonLifecycle lifecycle)
        {
            _logger.StartingProjection(this, lifecycle);

            _store.Schema.EnsureStorageExists(_projection.Produces);

            startConsumers();

            Lifecycle = lifecycle;
            _fetcher.Start(this, lifecycle, _cancellation.Token);


        }
コード例 #14
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     
 }
コード例 #15
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
 }
コード例 #16
0
ファイル: Fetcher.cs プロジェクト: phillip-haydon/marten
        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);
                }
            }
        }
コード例 #17
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     _writeline($"Starting projection {track.ViewType.FullName} running as {lifecycle}");
 }
コード例 #18
0
 public void StartingProjection(IProjectionTrack track, DaemonLifecycle lifecycle)
 {
     Logger.Information("Starting projection {Projection} with lifecycle {Lifecycle}", ToName(track), lifecycle);
 }