예제 #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="DocumentDbEventStore{TAggregateRoot, TEventSet}" /> class.
 /// </summary>
 /// <param name="client">The document DB client.</param>
 /// <param name="domainEventBus">The domain event bus.</param>
 /// <param name="snapshotRepository">The snapshot repository.</param>
 protected DocumentDbEventStore(DocumentClient client, IDomainEventBus domainEventBus,
                                ISnapshotRepository <TAggregateRoot> snapshotRepository)
 {
     Client             = client;
     DomainEventBus     = domainEventBus;
     SnapshotRepository = snapshotRepository;
 }
예제 #2
0
 public AggregateRepository(IEventSource eventSource, IEventBus eventBus, ISnapshotRepository snapshots, ISerializer serializer)
 {
     _eventSource = eventSource;
     _eventBus    = eventBus;
     _snapshots   = snapshots;
     _serializer  = serializer;
 }
예제 #3
0
 public HomeController(IAccountRepository accountRepository, ISnapshotRepository snapshotRepository, IArticleRepository articleRepository, IGalleryRepository galleryRepository)
 {
     _accountRepository  = accountRepository;
     _snapshotRepository = snapshotRepository;
     _articleRepository  = articleRepository;
     _galleryRepository  = galleryRepository;
 }
예제 #4
0
        private static void Serialize <TRepository>(ref JsonWriter writer, ISnapshotRepository value, IJsonFormatterResolver formatterResolver)
            where TRepository : class, ISnapshotRepository
        {
            var formatter = formatterResolver.GetFormatter <TRepository>();

            formatter.Serialize(ref writer, value as TRepository, formatterResolver);
        }
예제 #5
0
 public SnapshotAggregateRepository(ISnapshotRepository repository, IAggregateManifestRepository manifest, INotificationEventBus eventBus)
 {
     this.repository = repository;
     this.eventBus   = eventBus;
     this.manifest   = manifest;
     this.changes    = new Subject <IDataChangeEvent>();
 }
예제 #6
0
 public HandlerTests()
 {
     _eventBus     = new MemoryEventBus();
     _appendOnly   = new MemoryAppendOnlyStore(_eventBus);
     _eventStore   = new EventStore(_appendOnly);
     _snapShotRepo = new SnapshotRepository();
     _factory      = new AggregateFactory(_eventStore, _snapShotRepo);
 }
예제 #7
0
 public HandlerTests()
 {
     _queueService = new MemoryQueueService();
     _appendOnly   = new MemoryAppendOnlyStore(_queueService);
     _eventStore   = new EventStore(_appendOnly);
     _snapShotRepo = new SnapshotRepository();
     _factory      = new AggregateFactory(_eventStore, _snapShotRepo);
 }
 public CreateSnapshotUseCase(ILog log, IPotRepository potRepository,
                              IBlackListRepository blackListRepository, ISnapshotRepository snapshotRepository)
 {
     this.log                 = log ?? throw new ArgumentNullException(nameof(log));
     this.potRepository       = potRepository ?? throw new ArgumentNullException(nameof(potRepository));
     this.blackListRepository = blackListRepository ?? throw new ArgumentNullException(nameof(blackListRepository));
     this.snapshotRepository  = snapshotRepository ?? throw new ArgumentNullException(nameof(snapshotRepository));
 }
예제 #9
0
        public static IEnumerable <HFile> EnumerateFiles(this ISnapshotRepository snapshotRepository, SnapshotLocation snapshotLocation, BlackList blackList = null)
        {
            Snapshot snapshot = snapshotRepository.GetSnapshot(snapshotLocation);

            return(snapshot == null
                ? Enumerable.Empty <HFile>()
                : snapshot.EnumerateFiles(snapshotLocation.InternalPath, blackList));
        }
예제 #10
0
 public void Dispose()
 {
     _appendOnly   = null;
     _queueService = null;;
     _eventStore   = null;;
     _snapShotRepo = null;;
     _factory      = null;;
 }
 public SnapshotSerializer(
     IHaveState <TState> stateHolder,
     ISnapshotRepository <TState> repository,
     ILog log)
 {
     _stateHolder = stateHolder;
     _repository  = repository;
     _log         = log.CreateComponentScope($"{nameof(SnapshotSerializer<TState>)}[{_stateHolder.GetType().Name}]");
 }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public Repository(ITransitionStorage transitionStorage,
                   IEventBus eventBus,
                   IDataTypeRegistry dataTypeRegistry, ISnapshotRepository snapshotRepository = null)
 {
     _transitionStorage  = transitionStorage;
     _eventBus           = eventBus;
     _dataTypeRegistry   = dataTypeRegistry;
     _snapshotRepository = snapshotRepository;
 }
예제 #13
0
 public BalanceService(
     ILogFactory logFactory,
     IBalanceUpdateRepository balanceUpdateRepository,
     ISnapshotRepository snapshotRepository)
 {
     _log = logFactory.CreateLog(this);
     _balanceUpdateRepository = balanceUpdateRepository;
     _snapshotRepository      = snapshotRepository;
 }
예제 #14
0
 public ProjectionTests()
 {
     _resolver     = new MemoryResolver();
     _eventBus     = new MemoryEventBus(_resolver);
     _appendOnly   = new MemoryAppendOnlyStore(_eventBus);
     _eventStore   = new EventStore(_appendOnly, _eventBus);
     _snapShotRepo = new SnapshotRepository();
     _factory      = new AggregateFactory(_eventStore, _snapShotRepo);
 }
예제 #15
0
        /// <summary>
        /// Instantiates a repository that uses the given <see cref="ISnapshotRepository"/>
        /// </summary>
        /// <param name="snapshotRepository">The <see cref="ISnapshotRepository"/>. Cannot be null.</param>
        public SnapshotService(ISnapshotRepository snapshotRepository)
        {
            if (snapshotRepository == null)
            {
                throw new ArgumentNullException("snapshotRepository");
            }

            repository = snapshotRepository;
        }
예제 #16
0
 public EventStore(
     IEventBus eventBus,
     IDomainEventRepository <T> domainEventRepo,
     ISnapshotRepository <T> snapshotRepo,
     ISnapshotPolicy snapshotPlicy)
 {
     this.eventBus        = eventBus;
     this.snapshotRepo    = snapshotRepo;
     this.domainEventRepo = domainEventRepo;
     this.snapshotPlicy   = snapshotPlicy;
 }
예제 #17
0
        public AggregateRepository(Func<IAggregateRoot> factory, ISnapshotRepository snapshotRepository)
        {
            if (factory == null)
                throw new ArgumentNullException("factory");
            if (snapshotRepository == null)
                throw new ArgumentNullException("snapshotRepository");

            this.changes = new Subject<IDomainNotification>();
            this.factory = factory;
            this.snapshotRepository = snapshotRepository;
        }
예제 #18
0
        public AggregateRepository(Func<IAggregateRoot> factory, IEventStore eventStore, ISnapshotRepository snapshotRepository)
        {
            if (factory == null)
                throw new ArgumentNullException("factory");
            if (eventStore == null && snapshotRepository == null)
                throw new InvalidOperationException("eventStore or snapshotRepository is required");

            this.changes = new Subject<IDomainNotification>();
            this.factory = factory;
            this.eventStore = eventStore;
            this.snapshotRepository = snapshotRepository;
        }
예제 #19
0
 public SyncAgent(IMergableEventStore localEventStore,
                  IEventStore remoteEventStore,
                  IRepository <ISyncState> syncStateRepository,
                  IPendingCommandRepository pendingCommands,
                  ISnapshotRepository snapshotRepository)
 {
     this.localEventStore     = localEventStore;
     this.remoteEventStore    = remoteEventStore;
     this.syncStateRepository = syncStateRepository;
     this.pendingCommands     = pendingCommands;
     this.snapshotRepository  = snapshotRepository;
 }
예제 #20
0
 public MySqlAggregateSnapshotter(
     ISnapshotRepository snapshotRepository,
     IAggregateSnapshotSerializer aggregateSnapshotSerializer,
     ILoggerFactory loggerFactory,
     ITypeNameProvider typeNameProvider
     )
 {
     _snapshotRepository          = snapshotRepository;
     _aggregateSnapshotSerializer = aggregateSnapshotSerializer;
     _logger           = loggerFactory.Create(GetType().FullName);
     _typeNameProvider = typeNameProvider;
 }
예제 #21
0
        /// <summary>
        /// Saves a snapshot of the aggregate.
        /// </summary>
        public static async Task SaveSnapshot <TAggregate>(
            this ISnapshotRepository repository,
            TAggregate aggregate)
            where TAggregate : class, IEventSourced
        {
            var snapshotCreator = Configuration.Current.Container.Resolve <ICreateSnapshot <TAggregate> >();

            var snapshot = snapshotCreator.CreateSnapshot(aggregate);

            aggregate.InitializeSnapshot(snapshot);

            await repository.SaveSnapshot(snapshot);
        }
예제 #22
0
 public SnapshotService(ISnapshotRepository snapshotRepository, IReportService reportService)
 {
     if (snapshotRepository == null)
     {
         throw new ArgumentNullException("snapshotRepository");
     }
     if (reportService == null)
     {
         throw new ArgumentNullException("reportService");
     }
     this.reportService      = reportService;
     this.snapshotRepository = snapshotRepository;
 }
예제 #23
0
 public SnapshotService(ISnapshotRepository snapshotRepository, IReportService reportService)
 {
     if (snapshotRepository == null)
     {
         throw new ArgumentNullException("snapshotRepository");
     }
     if (reportService == null)
     {
         throw new ArgumentNullException("reportService");
     }
     this.reportService = reportService;
     this.snapshotRepository = snapshotRepository;
 }
예제 #24
0
        public AggregateRepository(Func <IAggregateRoot> factory, ISnapshotRepository snapshotRepository)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (snapshotRepository == null)
            {
                throw new ArgumentNullException("snapshotRepository");
            }

            this.changes            = new Subject <IDomainNotification>();
            this.factory            = factory;
            this.snapshotRepository = snapshotRepository;
        }
예제 #25
0
        public AggregateRepository(Func <IAggregateRoot> factory, IEventStore eventStore, ISnapshotRepository snapshotRepository)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (eventStore == null && snapshotRepository == null)
            {
                throw new InvalidOperationException("eventStore or snapshotRepository is required");
            }

            this.changes            = new Subject <IDomainNotification>();
            this.factory            = factory;
            this.eventStore         = eventStore;
            this.snapshotRepository = snapshotRepository;
        }
예제 #26
0
        public Solution(IEventRepository eventRepository, ISnapshotRepository snapshotRepository)
        {
            var eventStore        = new EventStore.EventStore(eventRepository);
            var snapshotStore     = new SnapshotStore(snapshotRepository);
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <SolutionContext>();
            serviceCollection.AddSingleton <ICommandBus>(new CommandBus(eventStore));
            serviceCollection.AddSingleton <IQueryBus>(new QueryBus());
            serviceCollection.AddSingleton <IEventBus>(new EventBus());
            serviceCollection.AddSingleton <IEventStore>(eventStore);
            serviceCollection.AddSingleton <ISnapshotStore>(snapshotStore);

            ServiceProvider = serviceCollection.BuildServiceProvider();
            ProjectorFactory.Init(EventStore);
        }
예제 #27
0
 public SavableMySqlAggregateSnapshotter(
     IAggregateSnapshotConfiguration aggregateSnapshotConfiguration,
     ISnapshotRepository snapshotRepository,
     IAggregateSnapshotSerializer aggregateSnapshotSerializer,
     IRepository repository,
     ILoggerFactory loggerFactory,
     ITypeNameProvider typeNameProvider
     )
 {
     _aggregateSnapshotConfiguration = aggregateSnapshotConfiguration;
     _snapshotRepository             = snapshotRepository;
     _aggregateSnapshotSerializer    = aggregateSnapshotSerializer;
     _repository       = repository;
     _logger           = loggerFactory.Create(GetType().FullName);
     _typeNameProvider = typeNameProvider;
 }
예제 #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            // Quick hack...
            DbServerPluginRegistry.RegisterPlugin(
                MsSql2014.Identifier,
                new MsSql2014DbServerInfo(),
                new MsSql2014DatabaseServices(),
                new MsSql2014SnapshotServices());

            this._connectionRepository = new ConnectionRepository();
            this._databaseRepository   = new DatabaseRepository();
            this._snapshotRepository   = new SnapshotRepository();

            this.UpdateButtonStatus();
        }
 public DistributionPlanService(
     IAssetsService assetService,
     IClaimedGasAmountRepository claimedGasAmountRepository,
     IDistributionPlanRepository distributionPlanRepository,
     ILogFactory logFactory,
     IMatchingEngineClient matchingEngineClient,
     ISnapshotRepository snapshotRepository,
     string gasAssetId)
 {
     _assetService = assetService;
     _claimedGasAmountRepository = claimedGasAmountRepository;
     _distributionPlanRepository = distributionPlanRepository;
     _gasAssetId           = gasAssetId;
     _log                  = logFactory.CreateLog(this);
     _matchingEngineClient = matchingEngineClient;
     _snapshotRepository   = snapshotRepository;
 }
예제 #30
0
        /// <summary>
        /// Saves a snapshot of the aggregate.
        /// </summary>
        public static async Task SaveSnapshot <TAggregate>(
            this ISnapshotRepository repository,
            TAggregate aggregate)
            where TAggregate : class, IEventSourced
        {
            var snapshotCreator = Configuration.Current.Container.Resolve <ICreateSnapshot <TAggregate> >();

            var snapshot = snapshotCreator.CreateSnapshot(aggregate);

            snapshot.AggregateId       = aggregate.Id;
            snapshot.AggregateTypeName = AggregateType <TAggregate> .EventStreamName;
            snapshot.LastUpdated       = Clock.Now();
            snapshot.Version           = aggregate.Version;
            snapshot.ETags             = aggregate.ETags()
                                         .Where(e => !string.IsNullOrWhiteSpace(e))
                                         .ToArray();

            await repository.SaveSnapshot(snapshot);
        }
예제 #31
0
        private static Snapshot GetSnapshot(this ISnapshotRepository snapshotRepository, SnapshotLocation snapshotLocation)
        {
            if (string.IsNullOrEmpty(snapshotLocation.PotName))
            {
                return(null);
            }

            if (snapshotLocation.SnapshotIndex.HasValue)
            {
                return(snapshotRepository.GetByIndex(snapshotLocation.PotName, snapshotLocation.SnapshotIndex.Value));
            }

            if (!snapshotLocation.SnapshotDate.HasValue)
            {
                return(snapshotRepository.GetLast(snapshotLocation.PotName));
            }

            DateTime searchedDate = snapshotLocation.SnapshotDate.Value;

            Snapshot snapshot = snapshotRepository.GetByExactDateTime(snapshotLocation.PotName, searchedDate);

            if (snapshot == null && searchedDate.TimeOfDay == TimeSpan.Zero)
            {
                List <Snapshot> snapshots = snapshotRepository.GetByDate(snapshotLocation.PotName, searchedDate)
                                            .ToList();

                if (snapshots.Count == 1)
                {
                    snapshot = snapshots[0];
                }
                else if (snapshots.Count > 1)
                {
                    throw new Exception($"There are multiple snapshots that match the specified date. Pot = {snapshotLocation.PotName}; Date = {searchedDate}");
                }
            }

            return(snapshot);
        }
		/// <summary>
		/// Register a custom repository
		/// </summary>
		public CreateRepositoryDescriptor Custom(ISnapshotRepository repository) => Assign(a => a.Repository = repository);
예제 #33
0
 public DeleteSnapshotUseCase(ISnapshotRepository snapshotRepository)
 {
     this.snapshotRepository = snapshotRepository ?? throw new ArgumentNullException(nameof(snapshotRepository));
 }
예제 #34
0
 public AccountService(ISnapshotRepository snapshotRepository, IAccountRepository accountRepository, IMapper mapper)
 {
     _snapshotRepository = snapshotRepository;
     _accountRepository  = accountRepository;
     _mapper             = mapper;
 }
예제 #35
0
 public SearchHandler(ISnapshotRepository injected)
 {
     reader = injected;
 }
        private async Task <bool> DeserializeAsync <TState>(ILog log, IHaveState <TState> stateHolder, ISnapshotRepository <TState> repository)
        {
            await log.WriteInfoAsync(nameof(DeserializeAsync), "", "Loading state...");

            var state = await repository.TryGetAsync();

            if (state == null)
            {
                await log.WriteWarningAsync("SnapshotSerializer", nameof(DeserializeAsync),
                                            stateHolder.GetType().Name, "No snapshot found to deserialize");

                return(false);
            }

            string stateDescription;

            try
            {
                stateDescription = stateHolder.DescribeState(state);
            }
            catch (NotSupportedException)
            {
                await log.WriteWarningAsync(nameof(DeserializeAsync), "", "Not supported, skipping");

                return(false);
            }

            await log.WriteInfoAsync(nameof(DeserializeAsync), stateDescription, "Settings state...");

            try
            {
                stateHolder.SetState(state);
            }
            catch (NotSupportedException)
            {
                await log.WriteWarningAsync(nameof(DeserializeAsync), "", "Not supported, skipping");

                return(false);
            }

            await log.WriteInfoAsync(nameof(DeserializeAsync), "", "State was set");

            return(true);
        }
 public virtual void SetUp()
 {
     this.SnapshotStore = new InMemorySnapshotRepository<TestSnapshot>();
 }