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)); }
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) } } }
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); } }
public ApertureAgent UseEventStream(IStreamEvents streamEvents) { _eventStream = streamEvents; return(this); }
public virtual async Task Run( IStreamEvents streamEvents, IProjectEvents projection, Action <Exception> handleException, CancellationToken ct) => await projection.ProjectAsync(streamEvents, ct);