public CollectionService(
     IEventStore eventStore, 
     IPublishEvents eventsPublisher)
 {
     this.eventStore = eventStore;
     this.eventsPublisher = eventsPublisher;
 }
Exemple #2
0
 public UserStoryService(
     IEventStore eventStore,
     IPublishEvents eventsPublisher)
 {
     this.eventsPublisher = eventsPublisher;
     this.eventStore = eventStore;
 }
        internal static async Task <PaymentCQRS> Build(BankPaymentStatus paymentStatus,
                                                       IGenerateBankPaymentId bankPaymentIdGenerator,
                                                       IConnectToAcquiringBanks bankConnectionBehavior,
                                                       IProvideBankResponseTime delayProvider,
                                                       IProvideTimeout providerForBankResponseWaiting,
                                                       IKnowBufferAndReprocessPaymentRequest knowBufferAndReprocessPaymentRequest,
                                                       IAmCircuitBreakers circuitBreakers,
                                                       IThrowsException gatewayExceptionSimulator = null,
                                                       IPublishEvents eventsPublisher             = null)
        {
            var bus = eventsPublisher ?? new InMemoryBus();
            var eventSourcedRepository = new EventSourcedRepository <Payment>(new InMemoryEventStore(bus));

            var appSettingsAccessor = Substitute.For <IOptionsMonitor <AppSettings> >();

            appSettingsAccessor.CurrentValue.Returns(new AppSettings {
                Executor = ExecutorType.Tests
            });

            var random = Substitute.For <IGenerateAcquiringBankPaymentStatus>();

            random.GeneratePaymentStatus().Returns(paymentStatus);

            var paymentsIdsMemory           = new PaymentIdsMemory();
            var bankAdapterSelector         = new BankAdapterSelector(random, bankPaymentIdGenerator, delayProvider, bankConnectionBehavior, paymentsIdsMemory, NullLogger <BankAdapterSelector> .Instance);
            var merchantToBankAdapterMapper = new MerchantToBankAdapterMapper(bankAdapterSelector);
            var paymentRequestsMemory       = new PaymentRequestsMemory();

            var paymentProcessor = new PaymentProcessor(eventSourcedRepository,
                                                        NullLogger <PaymentProcessor> .Instance,
                                                        providerForBankResponseWaiting,
                                                        knowBufferAndReprocessPaymentRequest,
                                                        circuitBreakers,

                                                        gatewayExceptionSimulator);

            var optionMonitor = Substitute.For <IOptionsMonitor <AppSettings> >();

            optionMonitor.CurrentValue.Returns(new AppSettings
            {
                Executor = ExecutorType.Tests
            });

            var paymentRequestCommandHandler = new PaymentRequestCommandHandler(eventSourcedRepository, paymentRequestsMemory, paymentProcessor, merchantToBankAdapterMapper, new RequestBankSynchronyMaster(optionMonitor), NullLogger <PaymentRequestCommandHandler> .Instance);
            var requestController            = new PaymentRequestsController(paymentRequestCommandHandler, NullLogger <PaymentRequestsController> .Instance);

            var readController = new PaymentReadController(eventSourcedRepository);

            var paymentDetailsRepository     = new PaymentDetailsRepository(NullLogger <PaymentDetailsRepository> .Instance);
            var paymentDetailsReadController = new PaymentsDetailsController(paymentsIdsMemory, paymentDetailsRepository);

            var readProjections = new ReadProjections(bus, paymentDetailsRepository);
            await readProjections.StartAsync(new CancellationToken(false));

            var gatewayPaymentsIdsController       = new GatewayPaymentsIdsController(paymentsIdsMemory);
            var acquiringBankPaymentsIdsController = new AcquiringBankPaymentsIdsController(paymentsIdsMemory);

            return(new PaymentCQRS(requestController, readController, paymentDetailsReadController, paymentRequestsMemory, paymentProcessor, gatewayPaymentsIdsController, acquiringBankPaymentsIdsController, readProjections));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="EventDispatcher"/>.
        /// </summary>
        /// <param name="eventStore">The event store.</param>
        /// <param name="eventPublisher">The event publisher.</param>
        /// <param name="settings">The current event store settings.</param>
        internal EventDispatcher(IStoreEvents eventStore, IPublishEvents eventPublisher, IStoreEventSettings settings)
        {
            Verify.NotNull(eventStore, nameof(eventStore));
            Verify.NotNull(eventPublisher, nameof(eventPublisher));

            this.eventStore = eventStore;
            this.eventPublisher = eventPublisher;
            this.markDispatched = settings.MarkDispatched;
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of <see cref="EventDispatcher"/>.
        /// </summary>
        /// <param name="eventStore">The event store.</param>
        /// <param name="eventPublisher">The event publisher.</param>
        /// <param name="settings">The current event store settings.</param>
        internal EventDispatcher(IStoreEvents eventStore, IPublishEvents eventPublisher, IStoreEventSettings settings)
        {
            Verify.NotNull(eventStore, nameof(eventStore));
            Verify.NotNull(eventPublisher, nameof(eventPublisher));

            this.eventStore     = eventStore;
            this.eventPublisher = eventPublisher;
            this.markDispatched = settings.MarkDispatched;
        }
 public SellTicketsService(
     IConcertRepository concertRepository,
     IBuyerRepository buyerRepository,
     ITicketsService ticketsService,
     IPublishEvents eventPublisher)
 {
     _concertRepository = concertRepository;
     _buyerRepository   = buyerRepository;
     _ticketsService    = ticketsService;
     _eventPublisher    = eventPublisher;
 }
Exemple #7
0
        protected BaseRepoSession(IHoldAllConfiguration configuration, IDisposable disposableHandle)
        {
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            this.disposableHandle = disposableHandle;

            NewEventsCollection = configuration.CollectionTypeSelector(stateType)();

            currentState = default(TState);

            this.eventPublisher = configuration.EventPublisher;

            EventApplier = this.configuration.EventApplier;
        }
Exemple #8
0
 public AlarmClock(IPublishEvents bus)
 {
     workerThread = new Thread(
         _ =>
     {
         while (!stopped)
         {
             lock (alarmLock)
             {
                 var now        = DateTime.UtcNow;
                 var shouldSend = alarms.Where(x => x.AlarmTime > now).ToList();
                 foreach (var alarm in shouldSend)
                 {
                     bus.Publish(alarm.Message);
                     alarms.Remove(alarm);
                 }
             }
             Thread.Sleep(1);
         }
     });
 }
 public PublishingPipelet(IPublishEvents publisher)
 {
     this.publisher = publisher;
 }
 public Waiter(string name, IPublishEvents next)
 {
     this.name = name;
     this.next = next;
 }
 public AssistantManager(IPublishEvents next)
 {
     this.next = next;
 }
Exemple #12
0
 public Cashier(IPublishEvents next)
 {
     this.next = next;
 }
 public EventsController(IPublishEvents publisher, IManageClaims claims) : base(claims)
 {
     _publisher = publisher;
 }
 public TestPipelineAdapter(IPublishEvents publisher)
 {
     this.publisher = publisher;
 }
Exemple #15
0
 public Chef(IPublishEvents next, string name, double efficiency = 1)
 {
     this.next       = next;
     this.efficiency = efficiency;
     this.name       = name;
 }
 public ChangeNameCommandHandler(IPublishEvents bus)
 {
     _bus = bus;
 }
Exemple #17
0
        /// <summary>
        /// Sets up telemetry to use topics to stream some <see cref="DomainEvent"/> types.
        /// </summary>
        /// <param name="bb">The <see cref="BigBrother"/> instance we are configuring.</param>
        /// <param name="publisher">The event publisher we are using to send events onto topics.</param>
        public static void PublishEventsToTopics(this IBigBrother bb, IPublishEvents publisher)
        {
            var bbImpl = bb as BigBrother ?? throw new InvalidOperationException($"Couldn't cast this instance of {nameof(IBigBrother)} to a concrete implementation of {nameof(BigBrother)}");

            bbImpl.TopicPublisher = publisher;
        }
Exemple #18
0
 public EventStore(IPublishEvents serviceBus)
 {
     _serviceBus = serviceBus;
 }
 public AddItemsToTheCart(IPublishEvents bus, ICreateBusinessEvents event_factory)
 {
   this.bus = bus;
   this.event_factory = event_factory;
 }
Exemple #20
0
 public EventStore(IPublishEvents eventPublisher)
 {
     _eventPublisher = eventPublisher;
 }
 public PaymentReadProjector(IPublishEvents bus, IPaymentDetailsRepository paymentDetailsRepository)
 {
     _bus = bus;
     _paymentDetailsRepository = paymentDetailsRepository;
 }
Exemple #22
0
 public RoboMom(IPublishEvents publisher)
 {
     this.publisher = publisher;
 }
 public TestPipelineAdapter(IPublishEvents publisher)
 {
     this.publisher = publisher;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="EventPublisherWrapper"/>
 /// </summary>
 /// <param name="bus">The event publisher to decorate.</param>
 /// <param name="statistics">The statistics class.</param>
 public EventPublisherWrapper(IPublishEvents bus, Statistics statistics)
 {
     this.statistics = statistics;
     this.bus = bus;
 }
Exemple #25
0
 public BookingStore(ISaveBooking saveBooking, IHandleClients handleClients, IPublishEvents publishEvents)
 {
     this.saveBooking   = saveBooking;
     this.handleClients = handleClients;
     this.publishEvents = publishEvents;
 }
Exemple #26
0
 public ReadProjections(IPublishEvents bus, IPaymentDetailsRepository paymentDetailsRepository)
 {
     _paymentReadProjector = new PaymentReadProjector(bus, paymentDetailsRepository);
 }
Exemple #27
0
 public InMemoryEventStore(IPublishEvents publisher)
 {
     _publisher = publisher;
 }
 public AccountRepository(IStoreEvents eventStore, IPublishEvents eventPublisher)
 {
     this.eventStore = eventStore;
     this.eventPublisher = eventPublisher;
 }
Exemple #29
0
 /// <summary>
 /// Initializes a new instance of <see cref="EventPublisherWrapper"/>
 /// </summary>
 /// <param name="bus">The event publisher to decorate.</param>
 /// <param name="statistics">The statistics class.</param>
 public EventPublisherWrapper(IPublishEvents bus, Statistics statistics)
 {
     this.statistics = statistics;
     this.bus        = bus;
 }
 public PublishingPipelet(IPublishEvents publisher, IEventSpecification eventFilter) : base(eventFilter)
 {
     this.publisher = publisher;
 }
Exemple #31
0
 internal Bus(ISerializeMessages serializer, ISendMessages sender, IPublishEvents publisher)
 {
     this.serializer = serializer;
     this.sender     = sender;
     this.publisher  = publisher;
 }
Exemple #32
0
 /// <summary>
 /// Initializes a new instance of <see cref="EventDispatcher"/>.
 /// </summary>
 /// <param name="eventStore">The event store.</param>
 /// <param name="eventPublisher">The event publisher.</param>
 public EventDispatcher(IStoreEvents eventStore, IPublishEvents eventPublisher)
     : this(eventStore, eventPublisher, Settings.EventStore)
 {
 }
 IManuallyConfigureEventAppliers IConfigureEventPublisher.WithEventPublisher(IPublishEvents publisher)
 {
     EventPublisher = publisher;
     return(new ApplierConfigurationBuilder(this));
 }
 public PublishingPipelet(IPublishEvents publisher)
 {
     this.publisher = publisher;
 }
Exemple #35
0
 public EventStore(IPublishEvents eventPublisher)
 {
     _eventPublisher = eventPublisher;
 }
Exemple #36
0
 public AlmacenarPedido(IPedidoRepository pedidoRepository, IClienteRepository clienteRepository, IPublishEvents publicarEventos)
 {
     this.pedidoRepository  = pedidoRepository;
     this.clienteRepository = clienteRepository;
     this.publicarEventos   = publicarEventos;
 }
 public EventStore(IPublishEvents serviceBus)
 {
     _serviceBus = serviceBus;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="EventDispatcher"/>.
 /// </summary>
 /// <param name="eventStore">The event store.</param>
 /// <param name="eventPublisher">The event publisher.</param>
 public EventDispatcher(IStoreEvents eventStore, IPublishEvents eventPublisher)
     : this(eventStore, eventPublisher, Settings.EventStore)
 {
 }
        public static WriteModelFacade BuildTheWriteModelHexagon(ISaveBooking saveBooking, IHandleClients handleClients, IPublishEvents eventPublisher, ISubscribeToEvents eventSubscriber)
        {
            var writeModelCommandHandler = new WriteModelFacade(new BookingStore(saveBooking, handleClients, eventPublisher));

            CompositionRootHelper.SubscribeCommands(writeModelCommandHandler, eventSubscriber);

            return(writeModelCommandHandler);
        }
Exemple #40
0
        public static async Task PublishAsync <T>(T input, string topic, ISerializeMessages serializer = null, IPublishEvents publisher = null) where T : class
        {
            serializer = serializer ?? new JSONSerializer();

            var newContext = new AFBusMessageContext
            {
                MessageID     = Guid.NewGuid(),
                TransactionID = Guid.NewGuid(),
                BodyType      = typeof(T).AssemblyQualifiedName
            };

            publisher = publisher ?? new AzureEventHubPublishTransport(serializer);


            await publisher.PublishEventsAsync(input, topic, newContext).ConfigureAwait(false);
        }
Exemple #41
0
        public static WriteModelFacade BuildTheWriteModelHexagon(IPedidoRepository grabarPedido, IClienteRepository manejarClientes, IPublishEvents eventPublisher, ISubscribeToEvents eventSubscriber)
        {
            var writeModelCommandHandler = new WriteModelFacade(new AlmacenarPedido(grabarPedido, manejarClientes, eventPublisher));

            CompositionRootHelper.SubscribeCommands(writeModelCommandHandler, eventSubscriber);

            return(writeModelCommandHandler);
        }
Exemple #42
0
 public Waiter(string name, IPublishEvents next)
 {
     this.name = name;
     this.next = next;
 }
 public CreateConcertService(IConcertRepository concertRepository, IPublishEvents eventPublisher)
 {
     _concertRepository = concertRepository;
     _eventPublisher    = eventPublisher;
 }