/// <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; }
public AggregateRepository(IEventSource eventSource, IEventBus eventBus, ISnapshotRepository snapshots, ISerializer serializer) { _eventSource = eventSource; _eventBus = eventBus; _snapshots = snapshots; _serializer = serializer; }
public HomeController(IAccountRepository accountRepository, ISnapshotRepository snapshotRepository, IArticleRepository articleRepository, IGalleryRepository galleryRepository) { _accountRepository = accountRepository; _snapshotRepository = snapshotRepository; _articleRepository = articleRepository; _galleryRepository = galleryRepository; }
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); }
public SnapshotAggregateRepository(ISnapshotRepository repository, IAggregateManifestRepository manifest, INotificationEventBus eventBus) { this.repository = repository; this.eventBus = eventBus; this.manifest = manifest; this.changes = new Subject <IDataChangeEvent>(); }
public HandlerTests() { _eventBus = new MemoryEventBus(); _appendOnly = new MemoryAppendOnlyStore(_eventBus); _eventStore = new EventStore(_appendOnly); _snapShotRepo = new SnapshotRepository(); _factory = new AggregateFactory(_eventStore, _snapShotRepo); }
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)); }
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)); }
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}]"); }
/// <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; }
public BalanceService( ILogFactory logFactory, IBalanceUpdateRepository balanceUpdateRepository, ISnapshotRepository snapshotRepository) { _log = logFactory.CreateLog(this); _balanceUpdateRepository = balanceUpdateRepository; _snapshotRepository = snapshotRepository; }
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); }
/// <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; }
public EventStore( IEventBus eventBus, IDomainEventRepository <T> domainEventRepo, ISnapshotRepository <T> snapshotRepo, ISnapshotPolicy snapshotPlicy) { this.eventBus = eventBus; this.snapshotRepo = snapshotRepo; this.domainEventRepo = domainEventRepo; this.snapshotPlicy = snapshotPlicy; }
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; }
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; }
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; }
public MySqlAggregateSnapshotter( ISnapshotRepository snapshotRepository, IAggregateSnapshotSerializer aggregateSnapshotSerializer, ILoggerFactory loggerFactory, ITypeNameProvider typeNameProvider ) { _snapshotRepository = snapshotRepository; _aggregateSnapshotSerializer = aggregateSnapshotSerializer; _logger = loggerFactory.Create(GetType().FullName); _typeNameProvider = typeNameProvider; }
/// <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); }
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; }
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; }
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; }
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); }
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; }
/// <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; }
/// <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); }
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);
public DeleteSnapshotUseCase(ISnapshotRepository snapshotRepository) { this.snapshotRepository = snapshotRepository ?? throw new ArgumentNullException(nameof(snapshotRepository)); }
public AccountService(ISnapshotRepository snapshotRepository, IAccountRepository accountRepository, IMapper mapper) { _snapshotRepository = snapshotRepository; _accountRepository = accountRepository; _mapper = mapper; }
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>(); }