Exemple #1
0
 public RabbitMqMessageFactory(
     ILog log,
     IEventJsonSerializer eventJsonSerializer)
 {
     _log = log;
     _eventJsonSerializer = eventJsonSerializer;
 }
Exemple #2
0
        public FilesEventStore(
            ILog log,
            IAggregateFactory aggregateFactory,
            IEventJsonSerializer eventJsonSerializer,
            IEnumerable <IMetadataProvider> metadataProviders,
            IEventUpgradeManager eventUpgradeManager,
            IJsonSerializer jsonSerializer,
            IFilesEventStoreConfiguration configuration)
            : base(log, aggregateFactory, eventJsonSerializer, eventUpgradeManager, metadataProviders)
        {
            _jsonSerializer = jsonSerializer;
            _configuration  = configuration;
            _logFilePath    = Path.Combine(_configuration.StorePath, "Log.store");

            if (File.Exists(_logFilePath))
            {
                var json          = File.ReadAllText(_logFilePath);
                var eventStoreLog = _jsonSerializer.Deserialize <EventStoreLog>(json);
                _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                _log = eventStoreLog.Log ?? new Dictionary <long, string>();

                if (_log.Count != _globalSequenceNumber)
                {
                    eventStoreLog         = RecreateEventStoreLog(_configuration.StorePath);
                    _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                    _log = eventStoreLog.Log;
                }
            }
            else
            {
                _log = new Dictionary <long, string>();
            }
        }
 public RabbitMqMessageFactory(
     ILog log,
     IEventJsonSerializer eventJsonSerializer)
 {
     _log = log;
     _eventJsonSerializer = eventJsonSerializer;
 }
Exemple #4
0
 public InMemoryEventStore(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEnumerable <IMetadataProvider> metadataProviders)
     : base(log, aggregateFactory, eventJsonSerializer, metadataProviders)
 {
 }
Exemple #5
0
 public RabbitConsumePersistenceService(IDispatchToEventSubscribers dispatchToEventSubscribers, EnvironmentConfiguration environmentConfiguration, IEventJsonSerializer eventJsonSerializer, IRabbitMqConfiguration rabbitMqConfiguration, IRabbitMqConnectionFactory rabbitMqConnectionFactory)
 {
     _dispatchToEventSubscribers = dispatchToEventSubscribers;
     _environmentConfiguration   = environmentConfiguration;
     _eventJsonSerializer        = eventJsonSerializer;
     _rabbitMqConfiguration      = rabbitMqConfiguration;
     _rabbitMqConnectionFactory  = rabbitMqConnectionFactory;
 }
Exemple #6
0
 public RabbitMqMessageFactory(
     ILog log,
     IEventJsonSerializer eventJsonSerializer,
     IRabbitMqConfiguration rabbitMqConfiguration)
 {
     _log = log;
     _eventJsonSerializer   = eventJsonSerializer;
     _rabbitMqConfiguration = rabbitMqConfiguration;
 }
Exemple #7
0
 public MsSqlEventStore(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEnumerable <IMetadataProvider> metadataProviders,
     IMsSqlConnection connection)
     : base(log, aggregateFactory, eventJsonSerializer, metadataProviders)
 {
     _connection = connection;
 }
Exemple #8
0
 public AggregateStore(IServiceProvider serviceProvider)
 {
     _serviceProvider           = serviceProvider;
     _logger                    = serviceProvider.GetRequiredService <ILogger <AggregateStore> >();
     _eventJsonSerializer       = serviceProvider.GetRequiredService <IEventJsonSerializer>();
     _persistenceFactory        = serviceProvider.GetRequiredService <IPersistenceFactory>();
     _aggregateFactory          = serviceProvider.GetRequiredService <IAggregateFactory>();
     _transientFaultHandler     = serviceProvider.GetRequiredService <ITransientFaultHandler <IOptimisticConcurrencyResilientStrategy> >();
     _cancellationConfiguration = serviceProvider.GetRequiredService <ICancellationConfiguration>();
 }
Exemple #9
0
 protected EventStore(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEnumerable <IMetadataProvider> metadataProviders)
 {
     Log = log;
     AggregateFactory    = aggregateFactory;
     EventJsonSerializer = eventJsonSerializer;
     MetadataProviders   = metadataProviders.ToList();
 }
Exemple #10
0
        public AppointmentBookCommandHandler(IMongoDbInsertOnlyReadModelStore <AppointmentInsertReadModel> mongoDbInsert, IDomainEventPublisher domainEventPublisher, IDomainEventFactory eventFactory, ISnapshotStore snapshotStore, IEventStore eventStore, IEventJsonSerializer jsonSerializer, IMongoDbEventSequenceStore sequenceStore)
        {
            this.domainEventPublisher = domainEventPublisher;
            this.sequenceStore        = sequenceStore;
            this.jsonSerializer       = jsonSerializer;
            this.eventStore           = eventStore;
            this.eventFactory         = eventFactory;

            this.mongoDbInsert = mongoDbInsert;
            this.snapshotStore = snapshotStore;
        }
Exemple #11
0
 public EventStoreEventStore(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEventUpgradeManager eventUpgradeManager,
     IEventStoreConnection connection,
     IEnumerable <IMetadataProvider> metadataProviders)
     : base(log, aggregateFactory, eventJsonSerializer, eventUpgradeManager, metadataProviders)
 {
     _connection = connection;
 }
        public async Task <IReadOnlyCollection <IDomainEvent> > CommitAsync(
            IEventJsonSerializer _eventJsonSerializer,
            ISourceId sourceId,
            CancellationToken cancellationToken)
        {
            if (!_exists)
            {
                await Persistence.Save(this, CancellationToken.None);
            }
            else
            {
                await Persistence.Update(this, CancellationToken.None);
            }

            await Persistence.Dispose(cancellationToken);

            if (_occuredEvents.HasItems())
            {
                var domainEvents = _occuredEvents
                                   .Select(e =>
                {
                    return(_eventJsonSerializer.Serialize(e.AggregateEvent, e.Metadata));
                })
                                   .Select((e, i) =>
                {
                    var committedDomainEvent = new CommittedDomainEvent
                    {
                        AggregateId             = Id.Value,
                        AggregateName           = e.Metadata[MetadataKeys.AggregateName],
                        AggregateSequenceNumber = e.AggregateSequenceNumber,
                        Data                 = e.SerializedData,
                        Metadata             = e.SerializedMetadata,
                        GlobalSequenceNumber = i + 1,
                    };
                    return(committedDomainEvent);
                })
                                   .Select(e => _eventJsonSerializer.Deserialize <TAggregate, TIdentity>(Id, e))
                                   .ToList();

                _occuredEvents.Clear();

                return(domainEvents);
            }
            else
            {
                _occuredEvents.Clear();
                return(new IDomainEvent <TAggregate, TIdentity>[] { });
            }
        }
Exemple #13
0
 public EventStoreBase(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEventUpgradeManager eventUpgradeManager,
     IEnumerable <IMetadataProvider> metadataProviders,
     IEventPersistence eventPersistence)
 {
     _eventPersistence = eventPersistence;
     _log = log;
     _aggregateFactory    = aggregateFactory;
     _eventJsonSerializer = eventJsonSerializer;
     _eventUpgradeManager = eventUpgradeManager;
     _metadataProviders   = metadataProviders.ToList();
 }
 public RabbitMqSubscriber(
     ILog log,
     IRabbitMqConnectionFactory connectionFactory,
     IRabbitMqConfiguration configuration,
     IRabbitMqMessageFactory rabbitMqMessageFactory,
     IEventJsonSerializer eventJsonSerializer,
     IDispatchToEventSubscribers dispatchToEventSubscribers
     )
 {
     _log = log;
     _connectionFactory          = connectionFactory;
     _configuration              = configuration;
     _rabbitMqMessageFactory     = rabbitMqMessageFactory;
     _eventJsonSerializer        = eventJsonSerializer;
     _dispatchToEventSubscribers = dispatchToEventSubscribers;
 }
Exemple #15
0
 public EventStoreBase(
     ILogger <EventStoreBase> logger,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEventUpgradeManager eventUpgradeManager,
     IEnumerable <IMetadataProvider> metadataProviders,
     IEventPersistence eventPersistence,
     ISnapshotStore snapshotStore)
 {
     _logger              = logger;
     _eventPersistence    = eventPersistence;
     _snapshotStore       = snapshotStore;
     _aggregateFactory    = aggregateFactory;
     _eventJsonSerializer = eventJsonSerializer;
     _eventUpgradeManager = eventUpgradeManager;
     _metadataProviders   = metadataProviders.ToList();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="log"></param>
 /// <param name="aggregateFactory"></param>
 /// <param name="eventJsonSerializer"></param>
 /// <param name="eventUpgradeManager"></param>
 /// <param name="metadataProviders"></param>
 /// <param name="eventPersistence"></param>
 /// <param name="snapshotStore"></param>
 /// <param name="dataRetrievalConfiguration"></param>
 public CustomEventStoreBase(
     ILog log,
     IAggregateFactory aggregateFactory,
     IEventJsonSerializer eventJsonSerializer,
     IEventUpgradeManager eventUpgradeManager,
     IEnumerable <IMetadataProvider> metadataProviders,
     IEventPersistence eventPersistence,
     ISnapshotStore snapshotStore, IDataRetrievalConfiguration dataRetrievalConfiguration)
 {
     _eventPersistence = eventPersistence;
     _snapshotStore    = snapshotStore;
     _log = log;
     _aggregateFactory           = aggregateFactory;
     _eventJsonSerializer        = eventJsonSerializer;
     _eventUpgradeManager        = eventUpgradeManager;
     _metadataProviders          = metadataProviders.ToList();
     _dataRetrievalConfiguration = dataRetrievalConfiguration;
 }
Exemple #17
0
        public SubscriptionBasedSingleAggregateReadStoreManager(
            ILog log,
            IResolver resolver,
            TReadModelStore readModelStore,
            IReadModelDomainEventApplier readModelDomainEventApplier,
            IReadModelFactory <TReadModel> readModelFactory,
            IEventJsonSerializer eventJsonSerializer,
            StreamsDBClient client)
        {
            Log            = log;
            Resolver       = resolver;
            ReadModelStore = readModelStore;
            ReadModelDomainEventApplier = readModelDomainEventApplier;
            ReadModelFactory            = readModelFactory;
            EventJsonSerializer         = eventJsonSerializer;
            Client = client;

            _cursorsStream = $"{typeof(TReadModel).Name.ToLowerInvariant()}-cursors";
        }
Exemple #18
0
 public EventsManagementModel(IEventJsonSerializer eventJsonSerializer, IEventPersistence eventPersistence)
 {
     _eventJsonSerializer = eventJsonSerializer ?? throw new ArgumentNullException(nameof(eventJsonSerializer));
     _eventPersistence    = eventPersistence ?? throw new ArgumentNullException(nameof(eventPersistence));
 }