Beispiel #1
0
        /// <summary>
        /// Unified method of dependency injection
        /// </summary>
        /// <returns></returns>
        protected virtual async ValueTask DependencyInjection()
        {
            this.VertexOptions      = this.ServiceProvider.GetService <IOptionsMonitor <ActorOptions> >().Get(this.ActorType.FullName);
            this.ArchiveOptions     = this.ServiceProvider.GetService <IOptionsMonitor <ArchiveOptions> >().Get(this.ActorType.FullName);
            this.Logger             = (ILogger)this.ServiceProvider.GetService(typeof(ILogger <>).MakeGenericType(this.ActorType));
            this.Serializer         = this.ServiceProvider.GetService <ISerializer>();
            this.EventTypeContainer = this.ServiceProvider.GetService <IEventTypeContainer>();
            this.SnapshotHandler    = this.ServiceProvider.GetService <ISnapshotHandler <TPrimaryKey, T> >();
            if (this.SnapshotHandler == default)
            {
                throw new VertexEventHandlerException(this.ActorType);
            }
            var eventStreamFactory = this.ServiceProvider.GetService <IEventStreamFactory>();

            this.EventStream = await eventStreamFactory.Create(this);

            var eventStorageFactory = this.ServiceProvider.GetService <IEventStorageFactory>();

            this.EventStorage = await eventStorageFactory.Create(this);

            var eventArchiveFactory = this.ServiceProvider.GetService <IEventArchiveFactory>();

            this.EventArchive = await eventArchiveFactory.Create(this);

            var snapshotStorageFactory = this.ServiceProvider.GetService <ISnapshotStorageFactory>();

            this.SnapshotStorage = await snapshotStorageFactory.Create(this);
        }
 public SnapshotSaverEngine(DbInstance dbInstance, ISnapshotStorage snapshotStorage,
                            ISnapshotSaverScheduler snapshotSaverScheduler)
 {
     _dbInstance             = dbInstance;
     _snapshotStorage        = snapshotStorage;
     _snapshotSaverScheduler = snapshotSaverScheduler;
 }
 public EventSourcingRepository(IEventStorage <TAggregate> eventStorage, ISnapshotStorage <TAggregate> snapshotStorage, IEventDispatcher eventDispatcher, TypeKeyDirectory typeKeyDirectory, Factory <TAggregate> aggregateFactory)
 {
     this.eventStorage     = eventStorage;
     this.snapshotStorage  = snapshotStorage;
     this.eventDispatcher  = eventDispatcher;
     this.typeKeyDirectory = typeKeyDirectory;
     this.aggregateFactory = aggregateFactory;
 }
Beispiel #4
0
 public SnapshotRepository(
     IEventStorage eventStorage,
     ISnapshotStorage snapshotStorage,
     ISnapshotStrategy snapshotStrategy,
     IDomainEventMediator domainEventMediator)
 {
     _snapshotStorage     = snapshotStorage ?? throw new ArgumentNullException(nameof(snapshotStorage));
     _snapshotStrategy    = snapshotStrategy ?? throw new ArgumentNullException(nameof(snapshotStrategy));
     _eventStorage        = eventStorage ?? throw new ArgumentNullException(nameof(eventStorage));
     _domainEventMediator = domainEventMediator ?? throw new ArgumentNullException(nameof(domainEventMediator));
 }
Beispiel #5
0
        /// <summary>
        /// Unified method of dependency injection
        /// </summary>
        /// <returns></returns>
        protected virtual async ValueTask DependencyInjection()
        {
            this.VertexOptions      = this.ServiceProvider.GetService <IOptionsMonitor <ShadowActorOptions> >().Get(this.ActorType.FullName);
            this.Serializer         = this.ServiceProvider.GetService <ISerializer>();
            this.EventTypeContainer = this.ServiceProvider.GetService <IEventTypeContainer>();
            this.Logger             = (ILogger)this.ServiceProvider.GetService(typeof(ILogger <>).MakeGenericType(this.ActorType));

            var snapshotStorageFactory = this.ServiceProvider.GetService <ISnapshotStorageFactory>();

            this.SnapshotStorage = await snapshotStorageFactory.Create(this);
        }
 public DefaultCommandProssor(
     IEventStore eventStore,
     IRepository repository,
     CommandHandleProvider commandHandleProvider,
     IEventPublisher eventPublisher,
     ISnapshotStorage snapshotStorage,
     IBinarySerializer binarySerializer)
 {
     _eventStore = eventStore;
     _repository = repository;
     _commandHandleProvider = commandHandleProvider;
     _eventPublisher = eventPublisher;
     _binarySerializer = binarySerializer;
     _snapshotStorage = snapshotStorage;
 }
        private static void SaveTransaction(ISnapshotStorage snapshotStorage, ExecutionMessage message)
        {
            ExecutionMessage sepTrade = null;

            if (message.HasOrderInfo && message.HasTradeInfo)
            {
                sepTrade = new ExecutionMessage
                {
                    HasTradeInfo  = true,
                    SecurityId    = message.SecurityId,
                    ServerTime    = message.ServerTime,
                    TransactionId = message.TransactionId,
                    ExecutionType = message.ExecutionType,
                    TradeId       = message.TradeId,
                    TradeVolume   = message.TradeVolume,
                    TradePrice    = message.TradePrice,
                    TradeStatus   = message.TradeStatus,
                    TradeStringId = message.TradeStringId,
                    OriginSide    = message.OriginSide,
                    Commission    = message.Commission,
                    IsSystem      = message.IsSystem,
                };

                message.HasTradeInfo  = false;
                message.TradeId       = null;
                message.TradeVolume   = null;
                message.TradePrice    = null;
                message.TradeStatus   = null;
                message.TradeStringId = null;
                message.OriginSide    = null;
            }

            snapshotStorage.Update(message);

            if (sepTrade != null)
            {
                snapshotStorage.Update(sepTrade);
            }
        }
 public ConfigurationController(IEventStorage eventStorage, ISnapshotStorage snapshotStorage, IEventBus eventBus)
 {
     _eventStorage    = eventStorage ?? throw new ArgumentNullException(nameof(eventStorage));
     _snapshotStorage = snapshotStorage ?? throw new ArgumentNullException(nameof(snapshotStorage));
     _eventBus        = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
 }
 public SnapshotStorageDecorator(ISnapshotStorage storage)
 {
     this.storage = storage;
 }
Beispiel #10
0
 public void SetSnapshotStorage(ISnapshotStorage store)
 {
     _snapshotStorage = store;
 }