public GeneralLedgerModule(EventStoreClient eventStore,
                                   IMessageTypeMapper messageTypeMapper, JsonSerializerOptions serializerOptions)
        {
            Build <OpenGeneralLedger>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle((_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             =
                    new GeneralLedgerHandlers(
                        new GeneralLedgerEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                        new GeneralLedgerEntryEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                        new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                return(handlers.Handle(command, ct));
            });
            Build <BeginClosingAccountingPeriod>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle((_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             =
                    new GeneralLedgerHandlers(
                        new GeneralLedgerEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                        new GeneralLedgerEntryEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                        new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                return(handlers.Handle(command, ct));
            });
        }
示例#2
0
 public CheckpointAwareProjector(Func <NpgsqlConnection> connectionFactory,
                                 IMessageTypeMapper messageTypeMapper, Projector[] projectors)
 {
     _connectionFactory = connectionFactory;
     _messageTypeMapper = messageTypeMapper;
     _projectors        = projectors;
 }
示例#3
0
 protected StreamStoreFeedProjection(string streamName, IMessageTypeMapper messageTypeMapper,
                                     JsonSerializerOptions?serializerOptions = null)
     : base(streamName)
 {
     _messageTypeMapper = messageTypeMapper;
     _serializerOptions = serializerOptions ?? TransactoSerializerOptions.Events;
 }
 public CheckpointAwareProjector(IStreamStore streamStore, IMessageTypeMapper messageTypeMapper,
                                 CheckpointedProjector[] projections)
 {
     _streamStore       = streamStore;
     _messageTypeMapper = messageTypeMapper;
     _projectors        = projections;
 }
示例#5
0
 public GeneralLedgerEventStoreRepository(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                          UnitOfWork unitOfWork)
 {
     _eventStore        = eventStore;
     _messageTypeMapper = messageTypeMapper;
     _unitOfWork        = unitOfWork;
     _inner             = new EventStoreRepository <GeneralLedger>(eventStore, unitOfWork, GeneralLedger.Factory, messageTypeMapper);
 }
示例#6
0
 public BusinessTransactionFeed(IMessageTypeMapper messageTypeMapper) : base("businessTransactions",
                                                                             messageTypeMapper)
 {
     When <BusinessTransaction>((e, _) => new BusinessTransactionEntry {
         TransactonId    = e.TransactionId,
         ReferenceNumber = e.ReferenceNumber
     });
 }
示例#7
0
 /// <summary>
 /// Constructs the step, getting the input queue address from the given <see cref="ITransport"/>
 /// </summary>
 public AssignDefaultHeadersStep(ITransport transport, IMessageTypeMapper messageTypeMapper, IRebusTime rebusTime, string defaultReturnAddressOrNull)
 {
     _rebusTime         = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime));
     _messageTypeMapper = messageTypeMapper ?? throw new ArgumentNullException(nameof(rebusTime));
     _senderAddress     = transport.Address;
     _returnAddress     = defaultReturnAddressOrNull ?? transport.Address;
     _hasOwnAddress     = !string.IsNullOrWhiteSpace(_senderAddress);
 }
示例#8
0
            public ReflectionMessageTypeMapper(Assembly messageAssembly, string?messageNamespace)
            {
                if (messageNamespace == null)
                {
                    throw new ArgumentNullException(messageNamespace);
                }

                _inner = new MessageTypeMapper(messageAssembly.DefinedTypes.Where(IsMessageType(messageNamespace)));
            }
示例#9
0
        public ChartOfAccountsModule(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                     JsonSerializerOptions serializerOptions)
        {
            Build <DefineAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle(async(_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new ChartOfAccountsHandlers(
                    new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                await handlers.Handle(command, ct);

                return(Position.Start);
            });

            Build <DeactivateAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle(async(_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new ChartOfAccountsHandlers(
                    new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                await handlers.Handle(command, ct);

                return(Position.Start);
            });

            Build <ReactivateAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle(async(_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new ChartOfAccountsHandlers(
                    new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                await handlers.Handle(command, ct);

                return(Position.Start);
            });

            Build <RenameAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle(async(_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new ChartOfAccountsHandlers(
                    new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                await handlers.Handle(command, ct);

                return(Position.Start);
            });
        }
示例#10
0
 public PurchaseOrderFeed(IMessageTypeMapper messageTypeMapper) : base("purchaseOrders", messageTypeMapper)
 {
     When <PurchaseOrderPlaced>((e, _) => new PurchaseOrderFeedEntry {
         PurchaseOrderId     = e.PurchaseOrderId,
         VendorId            = e.VendorId,
         PurchaseOrderNumber = e.PurchaseOrderNumber,
         Items = Array.ConvertAll(e.Items, item => new PurchaseOrderFeedEntry.Item {
             InventoryItemId = item.InventoryItemId,
             Quantity        = item.Quantity,
             UnitPrice       = item.UnitPrice
         })
     });
 }
示例#11
0
        internal JsonSerializer(IMessageTypeMapper messageTypeMapper, JsonSerializerSettings jsonSerializerSettings, Encoding encoding)
        {
            _settings          = jsonSerializerSettings;
            _encoding          = encoding;
            _messageTypeMapper = messageTypeMapper;

            if (!messageTypeMapper.UseTypeNameHandling)
            {
                _settings.TypeNameHandling = TypeNameHandling.None;
            }

            _encodingHeaderValue = $"{JsonContentType};charset={_encoding.HeaderName}";
        }
示例#12
0
 public EventStoreRepository(
     EventStoreClient eventStore,
     UnitOfWork unitOfWork,
     Func <TAggregateRoot> factory,
     IMessageTypeMapper messageTypeMapper,
     JsonSerializerOptions?serializerOptions = null)
 {
     _eventStore        = eventStore;
     _unitOfWork        = unitOfWork;
     _factory           = factory;
     _messageTypeMapper = messageTypeMapper;
     _serializerOptions = serializerOptions ?? DefaultOptions;
 }
        public StreamStoreProjectionHost(EventStoreClient eventStore, IMessageTypeMapper messageTypeMap,
                                         IStreamStore streamStore, params StreamStoreProjection[] projections)
        {
            _eventStore     = eventStore;
            _messageTypeMap = messageTypeMap;
            _streamStore    = streamStore;
            _projections    = projections;
            _stopped        = new CancellationTokenSource();

            _retryCount          = 0;
            _subscribed          = 0;
            _subscription        = null;
            _stoppedRegistration = null;
        }
示例#14
0
        public NpgSqlProjectionHost(EventStoreClient eventStore, IMessageTypeMapper messageTypeMap,
                                    Func <NpgsqlConnection> connectionFactory, params NpgsqlProjection[] projections)
        {
            _eventStore        = eventStore;
            _messageTypeMap    = messageTypeMap;
            _connectionFactory = connectionFactory;
            _projections       = projections;
            _stopped           = new CancellationTokenSource();

            _retryCount          = 0;
            _subscribed          = 0;
            _subscription        = null;
            _stoppedRegistration = null;
        }
示例#15
0
        public InventoryItemModule(EventStoreClient eventStore,
                                   IMessageTypeMapper messageTypeMapper, JsonSerializerOptions serializerOptions)
        {
            var handlers = new InventoryItemHandlers(new InventoryItemRepository(eventStore, messageTypeMapper));

            Build <DefineInventoryItem>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);

                return(Checkpoint.None);
            });
        }
示例#16
0
        public ProcessManagerHost(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                  string checkpointStreamName, ProcessManagerEventHandlerModule eventHandlerModule)
        {
            _eventStore           = eventStore;
            _messageTypeMapper    = messageTypeMapper;
            _checkpointStreamName = checkpointStreamName;
            _stopped = new CancellationTokenSource();

            _subscribed          = 0;
            _subscription        = null;
            _stoppedRegistration = null;
            _dispatcher          = new ProcessManagerEventDispatcher(eventHandlerModule);
            _checkpoint          = Checkpoint.None;
        }
        public InventoryItemModule(EventStoreClient eventStore,
                                   IMessageTypeMapper messageTypeMapper, JsonSerializerOptions serializerOptions)
        {
            Build <DefineInventoryItem>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, serializerOptions)
            .Handle((_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new InventoryItemHandlers(
                    new InventoryItemRepository(eventStore, messageTypeMapper, unitOfWork));

                return(handlers.Handle(command, ct));
            });
        }
示例#18
0
        public InMemoryProjectionHost(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                      InMemoryProjectionDatabase target, params ProjectionHandler <InMemoryProjectionDatabase>[][] projections)
        {
            _eventStore        = eventStore;
            _messageTypeMapper = messageTypeMapper;
            _target            = target;
            _stopped           = new CancellationTokenSource();

            _subscribed          = 0;
            _subscription        = null;
            _stoppedRegistration = null;

            _projector = new Projector <InMemoryProjectionDatabase>(
                EnvelopeResolve.WhenAssignableToHandlerMessageType(projections.SelectMany(_ => _).ToArray()));
        }
        public AccountingPeriodClosingModule(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                             AccountIsDeactivated accountIsDeactivated)
        {
            var handlers = new AccountingPeriodClosingHandlers(
                new GeneralLedgerEventStoreRepository(eventStore, messageTypeMapper),
                new GeneralLedgerEntryEventStoreRepository(eventStore, messageTypeMapper),
                new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper), accountIsDeactivated);

            Build <AccountingPeriodClosing>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);
                return(Checkpoint.None);
            });
        }
示例#20
0
        public GeneralLedgerEntryModule(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper,
                                        JsonSerializerOptions eventSerializerOptions, ICommandContext commandContext)
        {
            Build <PostGeneralLedgerEntry>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper, eventSerializerOptions, commandContext)
            .Handle((_, ct) => {
                var(unitOfWork, command) = _;
                var handlers             = new GeneralLedgerEntryHandlers(
                    new GeneralLedgerEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                    new GeneralLedgerEntryEventStoreRepository(eventStore, messageTypeMapper, unitOfWork),
                    new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper, unitOfWork));

                return(handlers.Handle(command, ct));
            });
        }
示例#21
0
        public ChartOfAccountsModule(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper)
        {
            var handlers =
                new ChartOfAccountsHandlers(new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper));

            Build <DefineAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);

                return(Checkpoint.None);
            });

            Build <DeactivateAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);

                return(Checkpoint.None);
            });

            Build <ReactivateAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);

                return(Checkpoint.None);
            });

            Build <RenameAccount>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);

                return(Checkpoint.None);
            });
        }
示例#22
0
        public GeneralLedgerModule(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper)
        {
            var handlers = new GeneralLedgerHandlers(
                new GeneralLedgerEventStoreRepository(eventStore, messageTypeMapper),
                new ChartOfAccountsEventStoreRepository(eventStore, messageTypeMapper));

            Build <OpenGeneralLedger>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);
                return(Checkpoint.None);
            });
            Build <BeginClosingAccountingPeriod>()
            .Log()
            .UnitOfWork(eventStore, messageTypeMapper)
            .Handle(async(command, ct) => {
                await handlers.Handle(command, ct);
                return(Checkpoint.None);
            });
        }
示例#23
0
 public InventoryItemRepository(EventStoreClient eventStore,
                                IMessageTypeMapper messageTypeMapper, UnitOfWork unitOfWork)
 {
     _inner = new EventStoreRepository <InventoryItem>(eventStore, unitOfWork, InventoryItem.Factory,
                                                       messageTypeMapper, TransactoSerializerOptions.Events);
 }
示例#24
0
 public static IMessageHandlerBuilder <TCommand, Checkpoint> UnitOfWork <TCommand>(
     this IMessageHandlerBuilder <TCommand, Checkpoint> builder, EventStoreClient eventStore,
     IMessageTypeMapper messageTypeMapper)
     where TCommand : class => builder.Pipe(next => async(message, ct) => {
 public ChartOfAccountsEventStoreRepository(EventStoreClient eventStore, IMessageTypeMapper messageTypeMapper)
 {
     _inner = new EventStoreRepository <ChartOfAccounts>(eventStore,
                                                         ChartOfAccounts.Factory, messageTypeMapper);
 }
 this ICommandHandlerBuilder <TCommand> builder, EventStoreClient eventStore,
 IMessageTypeMapper messageTypeMapper, JsonSerializerOptions eventSerializerOptions,
 ICommandContext?commandContext = null)
 internal DefaultXmlMessageTypeRecognizer(IMessageTypeMapper messageTypeMapper)
 {
     _messageTypeMapper = messageTypeMapper;
 }
示例#28
0
 public MessageTypeMapperTests()
 {
     _sut = MessageTypeMapper.Create(MessageTypeMapper.ScopedFromType(typeof(SomeEvent)));
 }
 public GeneralLedgerEntryEventStoreRepository(EventStoreClient eventStore,
                                               IMessageTypeMapper messageTypeMapper)
 {
     _inner = new EventStoreRepository <GeneralLedgerEntry>(eventStore,
                                                            GeneralLedgerEntry.Factory, messageTypeMapper);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NewtonsoftJsonSimpleProtocol"/> class.
 /// </summary>
 public NewtonsoftJsonSimpleProtocol(IMessageTypeMapper messageTypeMapper)
 {
     MessageTypeMapper = messageTypeMapper;
     PayloadSerializer = JsonSerializer.Create(CreateDefaultSerializerSettings());
 }