Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
 /// </summary>
 /// <param name="eventStoreClient">An event store client.</param>
 /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
 /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
 /// <param name="handlerResolver">A collection of handler modules to dispatch the commit to.</param>
 /// <exception cref="System.ArgumentNullException">
 /// eventStoreClient
 /// or
 /// checkpointRepository
 /// or
 /// dispatchCommit
 /// </exception>
 public DurableCommitDispatcher(
     [NotNull] IEventStoreClient eventStoreClient,
     [NotNull] ICheckpointRepository checkpointRepository,
     [NotNull] IHandlerResolver handlerResolver)
     : this(eventStoreClient, checkpointRepository, handlerResolver.DispatchCommit)
 {
 }
Beispiel #2
0
 public CheckpointService()
 {
     if (Repository == null)
     {
         Repository = new CheckpointRepository();
     }
 }
Beispiel #3
0
 protected ProjectionDispatcher(
     IProjectionHandlerResolver handlerResolver,
     ICheckpointRepository checkpointRepository)
 {
     _handlerResolver      = handlerResolver;
     _checkpointRepository = checkpointRepository;
 }
 public NEventStoreProjectionDispatcher(
     EventStoreClient eventStoreClient,
     IProjectionHandlerResolver handlerResolver,
     ICheckpointRepository checkpointRepository)
     : base(handlerResolver, checkpointRepository)
 {
     _eventStoreClient = eventStoreClient;
 }
 public NEventStoreProjectionDispatcher(
     EventStoreClient eventStoreClient,
     IProjectionHandlerResolver handlerResolver,
     ICheckpointRepository checkpointRepository)
     : base(handlerResolver, checkpointRepository)
 {
     _eventStoreClient = eventStoreClient;
 }
Beispiel #6
0
 public KinesisShardReaderBase(IAmazonKinesis client,
                               ICheckpointRepository checkpointRepository,
                               IHeartbeatService heartbeatService)
 {
     _client = client;
     CheckpointRepository = checkpointRepository;
     HeartbeatService     = heartbeatService;
 }
        public StreamProcessor(IBusFactory busFactory,
                               IAwsClientFactory awsClientFactory,
                               IAwsKinesisFactory awsKinesisFactory,
                               IOptions <AwsSettings> awsOptions,
                               IOptions <ServerSettings> serverOptions,
                               IMapper mapper,
                               ILogger <StreamProcessor> logger,
                               IMembershipService membershipService,
                               ICheckpointRepository checkpointRepository)
        {
            if (busFactory == null)
            {
                throw new ArgumentNullException(nameof(busFactory));
            }
            if (awsClientFactory == null)
            {
                throw new ArgumentNullException("awsClientFactory");
            }
            if (awsOptions == null)
            {
                throw new ArgumentNullException(nameof(awsOptions));
            }
            if (serverOptions == null)
            {
                throw new ArgumentNullException(nameof(serverOptions));
            }
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            _eventBus          = busFactory.CreateEventsBus();
            _kinesisFactory    = awsKinesisFactory;
            _mapper            = mapper;
            _logger            = logger;
            _membershipService = membershipService;
            _serverSettings    = serverOptions.Value;

            _checkpointRepository = checkpointRepository;

            var processedMeasurementStreamWriter = _kinesisFactory.CreateWriter();

            var recordProcessingFactory = new RecordProcessorFactory(membershipService, logger);

            _rawMeasurementsStreamReader = _kinesisFactory.CreateReader(
                recordProcessingFactory,
                _checkpointRepository,
                processedMeasurementStreamWriter);

            // Handle processed measurements.
            // Read from the processed measurements stream and publish out to
            // EasyNetQ/RabbitQ. This should be removed once
            // all other services (Web/MQTT/Notifier/Membership) are getting measurements
            // from the processed stream rather than the queue
            _processedMeasurementsStreamReader = _kinesisFactory.CreateProcesssedMeasurementsReader(
                _checkpointRepository,
                _eventBus);
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
 /// </summary>
 /// <param name="eventStoreClient">An event store client.</param>
 /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
 /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
 /// <param name="handlerModules">A collection of handler modules to dispatch the commit to.</param>
 /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs.
 /// If none specified TransientException.None is used.</param>
 /// <exception cref="System.ArgumentNullException">
 /// eventStoreClient
 /// or
 /// checkpointRepository
 /// or
 /// dispatchCommit
 /// </exception>
 public DurableCommitDispatcher(
     [NotNull] IEventStoreClient eventStoreClient,
     [NotNull] ICheckpointRepository checkpointRepository,
     [NotNull] IEnumerable <IHandlerResolver> handlerModules,
     TransientExceptionRetryPolicy retryPolicy = null) :
     this(eventStoreClient, checkpointRepository, handlerModules.DispatchCommit, retryPolicy)
 {
     Guard.EnsureNotNull(handlerModules, "handlerModule");
 }
Beispiel #9
0
 public EventObserverSubscriptionFactory(IStoreEvents eventStore, ICheckpointRepository checkpointRepo, IEnumerable <IObserver <ICommit> > commitObservers)
 {
     Contract.Requires <ArgumentNullException>(eventStore != null, "eventStore");
     Contract.Requires <ArgumentNullException>(checkpointRepo != null, "checkpointRepo");
     Contract.Requires <ArgumentNullException>(commitObservers != null, "commitObservers");
     this.checkpointRepo  = checkpointRepo;
     this.eventStore      = eventStore;
     this.commitObservers = commitObservers;
 }
 public ResolvedEventDispatcher(
     IEventStoreConnection eventStore,
     ISerializer serializer,
     ICheckpointRepository checkpoints,
     [NotNull] IHandlerResolver handlerResolver,
     Action onCaughtUp = null,
     string streamId = null,
     UserCredentials userCredentials = null)
     : this(eventStore, serializer, checkpoints, handlerResolver.DispatchResolvedEvent, onCaughtUp, streamId, userCredentials)
 {}
 public ProcessedMeasurementsShardReaderFactory(ICheckpointRepository checkpointRepository,
                                                IHeartbeatService heartbeatService,
                                                IBus bus,
                                                ILogger logger)
 {
     _checkpointRepository = checkpointRepository;
     _heartbeatService     = heartbeatService;
     _bus    = bus;
     _logger = logger;
 }
 public ProcessedMeasurementsKinesisShardReader(IAmazonKinesis client,
                                                ICheckpointRepository checkpointRepository,
                                                IHeartbeatService heartbeatService,
                                                IBus bus,
                                                ILogger logger)
     : base(client, checkpointRepository, heartbeatService)
 {
     _bus    = bus;
     _logger = logger;
 }
 public ResolvedEventDispatcher(
     IEventStoreConnection eventStore,
     ISerializer serializer,
     ICheckpointRepository checkpoints,
     [NotNull] IHandlerResolver handlerResolver,
     Action onCaughtUp = null,
     string streamId   = null,
     UserCredentials userCredentials = null)
     : this(eventStore, serializer, checkpoints, handlerResolver.DispatchResolvedEvent, onCaughtUp, streamId, userCredentials)
 {
 }
 public WayBillController(IWayBillRepository wayBillRepository, IDriverRepository driverRepository,
                          IVehicleRepository vehicleRepository, IRouteRepository routeRepository, ICheckpointRepository checkpointRepository,
                          IMedicNoteRepository medicNoteRepository, IMechanicNoteRepository mechanicNoteRepository)
 {
     this.wayBillRepository      = wayBillRepository ?? throw new ArgumentNullException(nameof(wayBillRepository));
     this.driverRepository       = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
     this.vehicleRepository      = vehicleRepository ?? throw new ArgumentNullException(nameof(vehicleRepository));
     this.routeRepository        = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
     this.checkpointRepository   = checkpointRepository ?? throw new ArgumentNullException(nameof(checkpointRepository));
     this.medicNoteRepository    = medicNoteRepository ?? throw new ArgumentNullException(nameof(medicNoteRepository));
     this.mechanicNoteRepository = mechanicNoteRepository ?? throw new ArgumentNullException(nameof(mechanicNoteRepository));
 }
Beispiel #15
0
 public RawMeasurementsKinesisShardReader(IAmazonKinesis client,
                                          ICheckpointRepository checkpointRepository,
                                          IHeartbeatService heartbeatService,
                                          IProcessedMeasurementStreamWriter processedMeasurementStreamWriter,
                                          IRecordProcessor recordProcessor,
                                          ILogger logger)
     : base(client, checkpointRepository, heartbeatService)
 {
     _processedMeasurementStreamWriter = processedMeasurementStreamWriter;
     _recordProcessor = recordProcessor;
     _logger          = logger;
 }
Beispiel #16
0
        public bool Start(IDomainRepository domainRepository, IEventStoreConnection connection, IEnumerable <Action <ICommand> > preExecutionPipe = null, IEnumerable <Action <object> > postExecutionPipe = null)
        {
            _connection           = connection;
            _domainEntry          = new DomainEntry(domainRepository, preExecutionPipe, postExecutionPipe);
            _checkpointRepository = new EventStoreCheckpointRepository(connection, CheckpointId);
            _latestPosition       = _checkpointRepository.Get();
            var settings = new CatchUpSubscriptionSettings(10, 100, false, true);

            _connection.SubscribeToAllFrom(_latestPosition, settings, HandleEvent);
            Console.WriteLine("AppServiceStrategy started");
            return(true);
        }
Beispiel #17
0
 public RawMeasurementsShardReaderFactory(IRecordProcessorFactory recordProcessorFactory,
                                          IProcessedMeasurementStreamWriter processedMeasurementStreamWriter,
                                          ICheckpointRepository checkpointRepository,
                                          IHeartbeatService heartbeatService,
                                          ILogger logger)
 {
     _recordProcessorFactory           = recordProcessorFactory;
     _processedMeasurementStreamWriter = processedMeasurementStreamWriter;
     _checkpointRepository             = checkpointRepository;
     _heartbeatService = heartbeatService;
     _logger           = logger;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
        /// </summary>
        /// <param name="eventStoreClient">An event store client.</param>
        /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
        /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
        /// <param name="dispatchCommit">A handler to dispatch the commit to.</param>
        /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs.
        /// If none specified TransientException.None is used.</param>
        /// <exception cref="System.ArgumentNullException">
        /// eventStoreClient
        /// or
        /// checkpointRepository
        /// or
        /// dispatchCommit
        /// </exception>
        public DurableCommitDispatcher(
            [NotNull] IEventStoreClient eventStoreClient,
            [NotNull] ICheckpointRepository checkpointRepository,
            [NotNull] Func<ICommit, CancellationToken, Task> dispatchCommit)
        {
            Ensure.That(eventStoreClient, "eventStoreClient").IsNotNull();
            Ensure.That(checkpointRepository, "checkpointRepository").IsNotNull();
            Ensure.That(dispatchCommit, "dispatchCommit").IsNotNull();

            _eventStoreClient = eventStoreClient;
            _checkpointRepository = checkpointRepository;
            _dispatchCommit = dispatchCommit;
        }
Beispiel #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
        /// </summary>
        /// <param name="eventStoreClient">An event store client.</param>
        /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
        /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
        /// <param name="dispatchCommit">A handler to dispatch the commit to.</param>
        /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs.
        /// If none specified TransientException.None is used.</param>
        /// <exception cref="System.ArgumentNullException">
        /// eventStoreClient
        /// or
        /// checkpointRepository
        /// or
        /// dispatchCommit
        /// </exception>
        public DurableCommitDispatcher(
            [NotNull] IEventStoreClient eventStoreClient,
            [NotNull] ICheckpointRepository checkpointRepository,
            [NotNull] Func <ICommit, CancellationToken, Task> dispatchCommit)
        {
            Ensure.That(eventStoreClient, "eventStoreClient").IsNotNull();
            Ensure.That(checkpointRepository, "checkpointRepository").IsNotNull();
            Ensure.That(dispatchCommit, "dispatchCommit").IsNotNull();

            _eventStoreClient     = eventStoreClient;
            _checkpointRepository = checkpointRepository;
            _dispatchCommit       = dispatchCommit;
        }
Beispiel #20
0
 public TaskService(IRTaskRepository taskRepository, IMapper mapper, ITeamRepository teamRepository, IProjectRepository projectRepository, SessionService sessionService, AttachmentService attachmentService, CommentService commentService, CheckPointService checkPointService, ICheckpointRepository checkpointRepository, IUserRepository userRepository)
 {
     this.taskRepository       = taskRepository;
     this.mapper               = mapper;
     this.teamRepository       = teamRepository;
     this.projectRepository    = projectRepository;
     this.checkpointRepository = checkpointRepository;
     this.sessionService       = sessionService;
     this.attachmentService    = attachmentService;
     this.checkPointService    = checkPointService;
     this.commentService       = commentService;
     this.userRepository       = userRepository;
 }
Beispiel #21
0
 public KinesisStreamReader(IAmazonKinesis client,
                            string streamName,
                            string readerName,
                            IShardReaderFactory shardReaderFactory,
                            ICheckpointRepository checkpointRepository,
                            ILogger logger)
 {
     _client               = client;
     _streamName           = streamName;
     _readerName           = readerName;
     _shardReaderFactory   = shardReaderFactory;
     _checkpointRepository = checkpointRepository;
     _logger               = logger;
 }
Beispiel #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
        /// </summary>
        /// <param name="eventStoreClient">An event store client.</param>
        /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
        /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
        /// <param name="dispatchCommit">A handler to dispatch the commit to.</param>
        /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs.
        /// If none specified TransientException.None is used.</param>
        /// <exception cref="System.ArgumentNullException">
        /// eventStoreClient
        /// or
        /// checkpointRepository
        /// or
        /// dispatchCommit
        /// </exception>
        public DurableCommitDispatcher(
            [NotNull] IEventStoreClient eventStoreClient,
            [NotNull] ICheckpointRepository checkpointRepository,
            [NotNull] Func <ICommit, CancellationToken, Task> dispatchCommit,
            TransientExceptionRetryPolicy retryPolicy = null)
        {
            Guard.EnsureNotNull(eventStoreClient, "eventStoreClient");
            Guard.EnsureNotNull(checkpointRepository, "checkpointRepository");
            Guard.EnsureNotNull(dispatchCommit, "dispatchCommit");

            _eventStoreClient     = eventStoreClient;
            _checkpointRepository = checkpointRepository;
            _dispatchCommit       = dispatchCommit;
            _retryPolicy          = retryPolicy ?? TransientExceptionRetryPolicy.None();
        }
Beispiel #23
0
 public Subscriber(
     IEventStoreConnection eventStoreConnection,
     ICheckpointRepository <Position> checkpointRepository,
     ILogger <Subscriber> logger,
     IConfiguration configuration,
     IMediator mediator,
     IDomainEventMapper domainEventMapper)
 {
     _eventStoreConnection = eventStoreConnection;
     _checkpointRepository = checkpointRepository;
     _logger            = logger;
     _configuration     = configuration;
     _mediator          = mediator;
     _domainEventMapper = domainEventMapper;
 }
        public IKinesisStreamReader CreateProcesssedMeasurementsReader(
            ICheckpointRepository checkpointRepository,
            IBus eventBus)
        {
            var streamName = _awsSettings.ProcessedMeasurementsStreamName;
            var client     = _clientFactory.CreateKinesisClient();

            ProcessedMeasurementsShardReaderFactory factory = new ProcessedMeasurementsShardReaderFactory(checkpointRepository,
                                                                                                          _heartbeatService,
                                                                                                          eventBus,
                                                                                                          _logger);

            return(new KinesisStreamReader(client,
                                           streamName,
                                           "Measurements",
                                           factory,
                                           checkpointRepository,
                                           _logger));
        }
        public ResolvedEventDispatcher(
            IEventStoreConnection eventStore,
            ISerializer serializer,
            ICheckpointRepository checkpoints,
            Func<ISerializer, ResolvedEvent, bool, CancellationToken, Task> dispatchResolvedEvent,
            Action onCaughtUp = null,
            string streamId = null,
            UserCredentials userCredentials = null)
        {
            _isStarted = new InterlockedBoolean();
            _isDisposed = new InterlockedBoolean();

            _eventStore = eventStore;
            _serializer = serializer;
            _checkpoints = checkpoints;
            _dispatchResolvedEvent = dispatchResolvedEvent;
            _onCaughtUp = onCaughtUp ?? (() => { });
            _streamId = streamId;
            _userCredentials = userCredentials;
            _projectedEvents = new Subject<ResolvedEvent>();

            _queue = new SimpleQueue(async (resolvedEvent, token) =>
            {
                try
                {
                    await _dispatchResolvedEvent(_serializer, resolvedEvent, _subscription.IsSubscribedToAll, _disposed.Token);
                }
                catch(Exception ex)
                {
                    _projectedEvents.OnError(ex);
                    throw;
                }

                if(_isDisposed.Value)
                {
                    return;
                }

                _projectedEvents.OnNext(resolvedEvent);

            }, _disposed.Token);
        }
        public IKinesisStreamReader CreateReader(IRecordProcessorFactory recordProcessorFactory,
                                                 ICheckpointRepository checkpointRepository,
                                                 IProcessedMeasurementStreamWriter processedMeasurementStreamWriter)
        {
            var streamName = _awsSettings.RawMeasurementsStreamName;
            var client     = _clientFactory.CreateKinesisClient();

            RawMeasurementsShardReaderFactory factory = new RawMeasurementsShardReaderFactory(recordProcessorFactory,
                                                                                              processedMeasurementStreamWriter,
                                                                                              checkpointRepository,
                                                                                              _heartbeatService,
                                                                                              _logger);

            return(new KinesisStreamReader(client,
                                           streamName,
                                           "",
                                           factory,
                                           checkpointRepository,
                                           _logger));
        }
        public ResolvedEventDispatcher(
            IEventStoreConnection eventStore,
            ISerializer serializer,
            ICheckpointRepository checkpoints,
            Func <ISerializer, ResolvedEvent, bool, CancellationToken, Task> dispatchResolvedEvent,
            Action onCaughtUp = null,
            string streamId   = null,
            UserCredentials userCredentials = null)
        {
            _isStarted  = new InterlockedBoolean();
            _isDisposed = new InterlockedBoolean();

            _eventStore            = eventStore;
            _serializer            = serializer;
            _checkpoints           = checkpoints;
            _dispatchResolvedEvent = dispatchResolvedEvent;
            _onCaughtUp            = onCaughtUp ?? (() => { });
            _streamId        = streamId;
            _userCredentials = userCredentials;
            _projectedEvents = new Subject <ResolvedEvent>();

            _queue = new SimpleQueue(async(resolvedEvent, token) =>
            {
                try
                {
                    await _dispatchResolvedEvent(_serializer, resolvedEvent, _subscription.IsSubscribedToAll, _disposed.Token);
                }
                catch (Exception ex)
                {
                    _projectedEvents.OnError(ex);
                    throw;
                }

                if (_isDisposed.Value)
                {
                    return;
                }

                _projectedEvents.OnNext(resolvedEvent);
            }, _disposed.Token);
        }
Beispiel #28
0
 public CheckPointService(ICheckpointRepository checkpointRepository, IMapper mapper, IRTaskRepository taskRepository)
 {
     this.checkpointRepository = checkpointRepository;
     this.mapper         = mapper;
     this.taskRepository = taskRepository;
 }
 public BackgroundEventProcessor(IIntegrationEventBus bus, IEventStoreConnection eventStore, ICheckpointRepository checkpointStore)
 {
     this._bus             = bus ?? throw new ArgumentNullException(nameof(bus));
     this._eventStore      = eventStore ?? throw new ArgumentNullException(nameof(eventStore));
     this._checkpointStore = checkpointStore ?? throw new ArgumentNullException(nameof(checkpointStore));
 }
 public ReadModelCommitObserver(ICheckpointRepository checkpointRepo, IDispatchCommits dispatcher)
 {
     Contract.Requires <ArgumentNullException>(checkpointRepo != null, "checkpointRepo");
     this.checkpointRepo = checkpointRepo;
     this.dispatcher     = dispatcher;
 }
 public TestProjectionDispatcher(IProjectionHandlerResolver handlerResolver, ICheckpointRepository checkpointRepository) 
     : base(handlerResolver, checkpointRepository)
 {}
 public RoutesController(IRouteRepository routeRepository, ICheckpointRepository checkpointRepository)
 {
     this.routeRepository      = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
     this.checkpointRepository = checkpointRepository ?? throw new ArgumentNullException(nameof(checkpointRepository));
 }
Beispiel #33
0
 public CheckpointsController(ICheckpointRepository repository)
 {
     this.repository = repository ?? throw new ArgumentNullException(nameof(repository));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class.
        /// </summary>
        /// <param name="eventStoreClient">An event store client.</param>
        /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/>
        /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param>
        /// <param name="dispatchCommit">A handler to dispatch the commit to.</param>
        /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs.
        /// If none specified TransientException.None is used.</param>
        /// <exception cref="System.ArgumentNullException">
        /// eventStoreClient
        /// or
        /// checkpointRepository
        /// or
        /// dispatchCommit
        /// </exception>
        public DurableCommitDispatcher(
            [NotNull] IEventStoreClient eventStoreClient,
            [NotNull] ICheckpointRepository checkpointRepository,
            [NotNull] Func<ICommit, CancellationToken, Task> dispatchCommit,
            TransientExceptionRetryPolicy retryPolicy = null)
        {
            Guard.EnsureNotNull(eventStoreClient, "eventStoreClient");
            Guard.EnsureNotNull(checkpointRepository, "checkpointRepository");
            Guard.EnsureNotNull(dispatchCommit, "dispatchCommit");

            _eventStoreClient = eventStoreClient;
            _checkpointRepository = checkpointRepository;
            _dispatchCommit = dispatchCommit;
            _retryPolicy = retryPolicy ?? TransientExceptionRetryPolicy.None();
            _compositeDisposable.Add(_commitsProjectedStream);
        }
Beispiel #35
0
 public MyoController(IUserRepository userRepository, IMyoRepository myoRepository, ICheckpointRepository checkpointRepository)
 {
     this.userRepository       = userRepository;
     this.myoRepository        = myoRepository;
     this.checkpointRepository = checkpointRepository;
 }
 public TestProjectionDispatcher(IProjectionHandlerResolver handlerResolver, ICheckpointRepository checkpointRepository)
     : base(handlerResolver, checkpointRepository)
 {
 }