public FilesEventPersistence(
            ILog log,
            IJsonSerializer jsonSerializer,
            IFilesEventStoreConfiguration configuration,
            IFilesEventLocator filesEventLocator)
        {
            _log = log;
            _jsonSerializer = jsonSerializer;
            _filesEventLocator = filesEventLocator;
            _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;
                _eventLog = eventStoreLog.Log ?? new Dictionary<long, string>();

                if (_eventLog.Count != _globalSequenceNumber)
                {
                    eventStoreLog = RecreateEventStoreLog(configuration.StorePath);
                    _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                    _eventLog = eventStoreLog.Log;
                }
            }
            else
            {
                _eventLog = new Dictionary<long, string>();
            }
        }
Example #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>();
            }
        }
Example #3
0
        public FilesEventPersistence(
            ILog log,
            IJsonSerializer jsonSerializer,
            IFilesEventStoreConfiguration configuration,
            IFilesEventLocator filesEventLocator)
        {
            _log               = log;
            _jsonSerializer    = jsonSerializer;
            _filesEventLocator = filesEventLocator;
            _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;
                _eventLog             = eventStoreLog.Log ?? new Dictionary <long, string>();

                if (_eventLog.Count != _globalSequenceNumber)
                {
                    eventStoreLog         = RecreateEventStoreLog(configuration.StorePath);
                    _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                    _eventLog             = eventStoreLog.Log;
                }
            }
            else
            {
                _eventLog = new Dictionary <long, string>();
            }
        }
Example #4
0
 public static EventFlowOptions UseFilesEventStore(
     this EventFlowOptions eventFlowOptions,
     IFilesEventStoreConfiguration filesEventStoreConfiguration)
 {
     eventFlowOptions.RegisterServices(f => f.Register(_ => filesEventStoreConfiguration, Lifetime.Singleton));
     eventFlowOptions.RegisterServices(f => f.Register <IEventStore, FilesEventStore>());
     return(eventFlowOptions);
 }
 public static IEventFlowOptions UseFilesEventStore(
     this IEventFlowOptions eventFlowOptions,
     IFilesEventStoreConfiguration filesEventStoreConfiguration)
 {
     return(eventFlowOptions.RegisterServices(f => {
         f.Register(_ => filesEventStoreConfiguration, Lifetime.Singleton);
         f.Register <IEventPersistence, FilesEventPersistence>();
         f.Register <IFilesEventLocator, FilesEventLocator>();
     }));
 }
 public static IEventFlowOptions UseFilesEventPersistence(
     this IEventFlowOptions eventFlowOptions,
     IFilesEventStoreConfiguration filesEventStoreConfiguration)
 {
     eventFlowOptions.ServiceCollection
     .AddSingleton(filesEventStoreConfiguration)
     .AddSingleton <IEventPersistence, FilesEventPersistence>()
     .AddTransient <IFilesEventLocator, FilesEventLocator>();
     return(eventFlowOptions);
 }
Example #7
0
        protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
        {
            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            Directory.CreateDirectory(storePath);

            var resolver = eventFlowOptions
                           .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                           .CreateResolver();

            _configuration = resolver.Resolve <IFilesEventStoreConfiguration>();

            return(resolver);
        }
Example #8
0
        protected override IServiceProvider Configure(IEventFlowOptions eventFlowOptions)
        {
            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            Directory.CreateDirectory(storePath);

            var serviceProvider = eventFlowOptions
                                  .UseFilesEventPersistence(FilesEventStoreConfiguration.Create(storePath))
                                  .ServiceCollection.BuildServiceProvider();

            _configuration = serviceProvider.GetRequiredService <IFilesEventStoreConfiguration>();

            return(serviceProvider);
        }
        protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
        {
            var storePath = Path.Combine(
                Path.GetTempPath(),
                Guid.NewGuid().ToString());

            Directory.CreateDirectory(storePath);

            var resolver = eventFlowOptions
                .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                .CreateResolver();

            _configuration = resolver.Resolve<IFilesEventStoreConfiguration>();

            return resolver;
        }
Example #10
0
            public override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
            {
                var storePath = Path.Combine(
                    Path.GetTempPath(),
                    Guid.NewGuid().ToString());

                Directory.CreateDirectory(storePath);

                var resolver = eventFlowOptions
                               .UseInMemoryReadStoreFor <InMemoryTestAggregateReadModel>()
                               .UseFilesEventStore(FilesEventStoreConfiguration.Create(storePath))
                               .CreateResolver();

                _configuration      = resolver.Resolve <IFilesEventStoreConfiguration>();
                _readModelPopulator = resolver.Resolve <IReadModelPopulator>();
                _queryProcessor     = resolver.Resolve <IQueryProcessor>();

                return(resolver);
            }
 public FilesEventLocator(
     IFilesEventStoreConfiguration configuration)
 {
     _configuration = configuration;
 }
Example #12
0
 public FilesEventLocator(
     IFilesEventStoreConfiguration configuration)
 {
     _configuration = configuration;
 }