示例#1
0
        public async Task Run(
            IStreamEvents streamEvents,
            IProjectEvents projection,
            Action <Exception> handleException,
            CancellationToken ct)
        {
            var delay = Backoff.DecorrelatedJitterBackoffV2(
                medianFirstRetryDelay: _config.FirstRetryDelay,
                retryCount: _config.RetryCount);

            await Policy
            .Handle <ApertureProjectionException>()
            .WaitAndRetryAsync(delay, (ex, _) => handleException(ex))
            .ExecuteAsync(
                async() => await projection.ProjectAsync(streamEvents, ct));
        }
示例#2
0
 public override async Task Run(
     IStreamEvents streamEvents,
     IProjectEvents projection,
     Action <Exception> handleException,
     CancellationToken ct)
 {
     while (true)
     {
         try
         {
             await base.Run(streamEvents, projection, handleException, ct);
         }
         catch (ApertureProjectionException e)
         {
             handleException(e);
             // TODO - Add max restarts and check max restart count (per projection)
         }
     }
 }
示例#3
0
        public async Task ProjectAsync(IStreamEvents streamEvents, CancellationToken ct)
        {
            var projection       = GetType();
            var projectionOffset = await _offsetTracker.GetOffsetAsync(projection);

            try
            {
                await streamEvents.SubscribeAsync(
                    projection,
                    projectionOffset,
                    ct,
                    async data => await TrackAndHandleEventAsync(projection, data));
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ApertureProjectionException(
                          "Exception encountered while projecting events, see inner exception for more details", e);
            }
        }
示例#4
0
        public ApertureAgent UseEventStream(IStreamEvents streamEvents)
        {
            _eventStream = streamEvents;

            return(this);
        }
示例#5
0
 public virtual async Task Run(
     IStreamEvents streamEvents,
     IProjectEvents projection,
     Action <Exception> handleException,
     CancellationToken ct) =>
 await projection.ProjectAsync(streamEvents, ct);