public RepositoryScenarioBuilder() { _eventStore = Wireup.Init().UsingInMemoryPersistence().Build(); _unitOfWork = new UnitOfWork(); _eventStoreSchedule = new List<Action<IStoreEvents>>(); _unitOfWorkSchedule = new List<Action<UnitOfWork>>(); }
public static Core UseNEventStore(this Core core, IStoreEvents nEventStore) { if (core.GetContainer().Model.HasImplementationsFor<IEventStore>()) { throw new EventStoreAlreadyConfiguredException(); } try { core.GetContainer() .Configure( expression => expression.For<IEventStore>() .Singleton() .Use<NEventStore>() .Ctor<IStoreEvents>() .Is(nEventStore)); } catch (Exception) { throw new Exception("Failed to execute wireup for event store."); } return core; }
public Rebuild(IStoreEvents eventStore, IDomainUpdateServiceBusHandlerHook hook, ILifetimeScope container, IMongoContext mongo) { _eventStore = eventStore; _hook = hook; _container = container; _mongo = mongo; }
public Program(IMessageSender sender, IStoreEvents store, NuclearStorage storage) { this.sender = new SenderDecorator(sender); this.store = store; this.storage = storage; reader = new ConsoleReader(); }
public void SetUp() { streamId = Guid.NewGuid().ToString(); store = TestEventStore.Create(); store.Populate(streamId); stream = NEventStoreStream.ByAggregate(store, streamId); }
public EventsReplayer(IStoreEvents store, IBus bus) { Contract.Requires<ArgumentNullException>(store != null, "store"); Contract.Requires<ArgumentNullException>(bus != null, "bus"); _store = store; _bus = bus; }
public static void Init() { StoreEvents = Wireup.Init() //.UsingInMemoryPersistence() .UsingSqlPersistence("EventStore") // Connection string is in app.config .WithDialect(new PostgreSqlDialect()) .EnlistInAmbientTransaction() // two-phase commit .InitializeStorageEngine() //.TrackPerformanceInstance("example") .UsingJsonSerialization() //.Compress() //.EncryptWith(EncryptionKey) //.HookIntoPipelineUsing(new[] { new AuthorizationPipelineHook() }) //.UsingSynchronousDispatchScheduler() //.DispatchTo(new DelegateMessageDispatcher(DispatchCommit)) .Build(); var connectionString = ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString; var connection = new NpgsqlConnection(connectionString); connection.Open(); var sql = @" CREATE TABLE IF NOT EXISTS ""LigaView"" ( ""Id"" uuid NOT NULL, ""Name"" varchar NOT NULL );"; connection.Execute(sql); connection.Close(); }
public void SetUp() { // populate the event store store = TestEventStore.Create(); streamSource = new NEventStoreStreamSource(store); }
public LegacySnapshotCreator(IStoreEvents store, IDatabase database) { Contract.Requires<ArgumentNullException>(store != null, "store"); Contract.Requires<ArgumentNullException>(database != null, "database"); _store = store; _db = database; }
public Persistence() { using (var scope = new TransactionScope()) { store = WireupEventStore(); } this.setConnection(true); }
public NEventStore(IStoreSettings<IStoreEvents> settings, IServiceBus serviceBus) { _settings = settings; _serviceBus = serviceBus; _store = _settings.GetConnection(); _eventStream = _store.OpenStream("main"); }
public LessonMigration(IDatabase database, IStoreEvents storeEvent) { Contract.Requires<ArgumentNullException>(database != null, "database"); Contract.Requires<ArgumentNullException>(storeEvent != null, "storeEvent"); _db = database; _store = storeEvent; _logs = new List<string>(); }
public RebuildSnapshotTask(ILogger log, IStoreEvents events, IRepository repository) { if (log == null) throw new ArgumentNullException("log"); if (events == null) throw new ArgumentNullException("events"); if (repository == null) throw new ArgumentNullException("repository"); this.log = log; this.events = events; this.repository = repository; }
protected override void Context() { _dummyDispatchCommits = new DummyDispatchCommits(); _eventStore = Wireup .Init() .UsingInMemoryPersistence() .DoNotDispatchCommits() .Build(); }
static void Main(string[] args) { store = Wireup.Init() .With<ISerialize>(new JsonPayloadSerializer()) .UserSimpleDataPersistenceEngine("SD_ES") .Build(); LoadTest(); }
/// <summary> /// Initializes a new instance of <see cref="EventDispatcher"/>. /// </summary> /// <param name="eventStore">The event store.</param> /// <param name="eventPublisher">The event publisher.</param> /// <param name="settings">The current event store settings.</param> internal EventDispatcher(IStoreEvents eventStore, IPublishEvents eventPublisher, IStoreEventSettings settings) { Verify.NotNull(eventStore, nameof(eventStore)); Verify.NotNull(eventPublisher, nameof(eventPublisher)); this.eventStore = eventStore; this.eventPublisher = eventPublisher; this.markDispatched = settings.MarkDispatched; }
protected override void Context() { _dummyDispatchCommits = new DummyDispatchCommits(); _eventStore = Wireup .Init() .UsingInMemoryPersistence() .UsingAsynchronousDispatchScheduler(_dummyDispatchCommits) .Build(); }
public static void Show(IStoreEvents store) { eventStore = store; OpenOrCreateStream(); AppendToStream(); TakeSnapshot(); LoadFromSnapshotForwardAndAppend(); }
public SourceStore() { //TODO: Setup your source store here _store = Wireup.Init().UsingInMemoryPersistence().InitializeStorageEngine().Build(); //Uncomment if you want to add some test data //CreateTestStream(); _commits = _store.Advanced.GetFrom(DateTime.MinValue).GetEnumerator(); }
public void Setup() { BsonClassMap.RegisterClassMap<InventoryItemCreated>(); BsonClassMap.RegisterClassMap<InventoryItemStocked>(); _store = Wireup.Init() .UsingMongoPersistence("demo", new DocumentObjectSerializer()) .InitializeStorageEngine() .Build(); }
public MongoEventReplayer(Type eventType, IEnumerable<Handles<IEvent>> eventHandlerInstances, IStoreEvents eventStore, MongoDatabase readModelDatabase) { if (eventType == null) throw new ArgumentNullException("eventType"); if (eventStore == null) throw new ArgumentNullException("eventStore"); if (readModelDatabase == null) throw new ArgumentNullException("readModelDatabase"); _eventHandlerInstances = eventHandlerInstances; _eventStore = eventStore; _readModelDatabase = readModelDatabase; }
public DenormalizerRebuilder(IDenormalizerCatalog catalog, IDenormalizersHashesStore hashesStore, IHashcodeGenerator hashcodeGenerator, IDomainEventHandlerCatalog domainEventCatalog, IStoreEvents eventStore, ILogger logger) { _catalog = catalog; _eventStore = eventStore; _hashcodeGenerator = hashcodeGenerator; _domainEventHandlerCatalog = domainEventCatalog; _denormalizersHashesStore = hashesStore; _logger = logger; }
public LoginCommand() { var test = new CommitDispatcher(); _store = Wireup.Init() .UsingRavenPersistence("RavenDb") .InitializeStorageEngine() .UsingSynchronousDispatchScheduler() .DispatchTo(test) .Build(); }
public void CanBuildStore() { Directory.CreateDirectory(_Directory); _Store = Wireup.Init() .UsingDiskStoragePersistence(_Directory) .InitializeStorageEngine() .UsingSynchronousDispatchScheduler( new DelegateMessageDispatcher((commit) => { LastCommit = commit.CommitId; })) .Build(); }
public EventStreamController( IStoreEvents eventStore, ICommitEnhancer enhancer, IHandleMapper handleMapper, IIdentityConverter identityConverter) { _enhancer = enhancer; _commits = (ICommitEvents)eventStore; _handleMapper = handleMapper; _identityConverter = identityConverter; }
protected override void Context() { _dummyDispatchCommits = new DummyDispatchCommits(); _eventStore = Wireup .Init() .UsingInMemoryPersistence() .UsingSynchronousDispatchScheduler() .DispatchTo(_dummyDispatchCommits) .Startup(DispatcherSchedulerStartup.Explicit) .Build(); }
public JoesUnitOfWork(Guid commandId, IDomainRepository domainRepository, IStoreEvents eventStore, ISnapshotStore snapshotStore, IEventBus eventBus, ISnapshottingPolicy snapshottingPolicy) : base(commandId) { _eventStream = new UncommittedEventStream(commandId); _commitId = commandId; _eventStore = eventStore; _domainRepository = domainRepository; _snapshotStore = snapshotStore; _eventBus = eventBus; _snapshottingPolicy = snapshottingPolicy; }
public MongoDBEventStore(IEventBus bus) { if (bus == null) throw new ArgumentNullException("bus"); _bus = bus; _store = Wireup.Init() .LogToOutputWindow() .UsingMongoPersistence("Mongo", new DocumentObjectSerializer()) .InitializeStorageEngine() .UsingSynchronousDispatchScheduler(this) .Build(); }
public void SetUp() { // populate the event store store = TestEventStore.Create(); streamId = Guid.NewGuid().ToString(); store.WriteEvents(streamId); stream = NEventStoreStream.ByAggregate(store, streamId).DomainEvents(); }
public EventStoreRecordStorage(IIdentity identity, IStoreEvents storage, ILogger logger) { if (storage == null) throw new ArgumentException("storage"); m_identity = identity; m_storage = storage; m_logger = logger; if (!Guid.TryParse(identity.GetIdenfitier(), out m_streamID)) throw new DomainException("Identity can not be converted to guid. Identity id: {0}", m_identity.GetIdenfitier()); }
/// <summary> /// Create `NEventStore` implementation of `IOutbox`. /// </summary> /// <param name="eventStore">NEventStore instance</param> /// <param name="receptionDelay"> /// It should include transaction timeout + clock drift. /// Otherwise, it may skip events during reception. /// </param> public NEventStoreOutbox(IStoreEvents eventStore, TimeSpan receptionDelay) { _eventStore = eventStore; _receptionDelay = receptionDelay; }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream to be created.</param> /// <returns>An empty stream.</returns> public static IEventStream CreateStream(this IStoreEvents storeEvents, Guid streamId) { return(CreateStream(storeEvents, Bucket.Default, streamId)); }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="bucketId">The value which uniquely identifies bucket the stream belongs to.</param> /// <param name="streamId">The value which uniquely identifies the stream within the bucket to be created.</param> /// <returns>An empty stream.</returns> public static IEventStream CreateStream(this IStoreEvents storeEvents, string bucketId, Guid streamId) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.CreateStream(bucketId, streamId.ToString())); }
protected Projector( ILogger <TProject> logger, IStoreEvents events, TProject process, int batchSize, TimeSpan timeout) { _logger = logger; _events = events; _timer = new Timer(time => { _batch.TriggerBatch(); }); _queue = new BufferBlock <Envelope>(); _trigger = new TransformBlock <Envelope, Envelope>( envelope => { _timer.Change(timeout, Timeout.InfiniteTimeSpan); return(envelope); } ); _batch = new BatchBlock <Envelope>(batchSize); _process = new TransformBlock <Envelope[], ProjectionResult[]>(async envelopes => { var time = DateTime.Now; try { var results = new ProjectionResult[envelopes.Length]; for (var i = 0; i < envelopes.Length; i++) { results[i] = new ProjectionResult { Envelope = envelopes[i], Projection = await process.Project(envelopes[i]), }; } return(results); } finally { _logger.LogDebug($"Processed {envelopes.Length} events in {(DateTime.Now - time).TotalMilliseconds}ms"); } }); _commit = new ActionBlock <ProjectionResult[]>(async envelopes => { _timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); var time = DateTime.Now; try { await Commit(envelopes); } finally { _logger.LogInformation($"Committed {envelopes.Length} projections in {(DateTime.Now - time).TotalMilliseconds}ms"); } }); _queue.LinkTo(_trigger, new DataflowLinkOptions { PropagateCompletion = true }); _trigger.LinkTo(_batch, new DataflowLinkOptions { PropagateCompletion = true }); _batch.LinkTo(_process, new DataflowLinkOptions { PropagateCompletion = true }); _process.LinkTo(_commit, new DataflowLinkOptions { PropagateCompletion = true }); }
/// <summary> /// Reads the stream indicated from the minimum revision specified up to the maximum revision specified or creates /// an empty stream if no commits are found and a minimum revision of zero is provided. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="bucketId">The value which uniquely identifies bucket the stream belongs to.</param> /// <param name="streamId">The value which uniquely identifies the stream within the bucket to be created.</param> /// <param name="minRevision">The minimum revision of the stream to be read.</param> /// <param name="maxRevision">The maximum revision of the stream to be read.</param> /// <returns>A series of committed events represented as a stream.</returns> /// <exception cref="StorageException" /> /// <exception cref="StorageUnavailableException" /> /// <exception cref="StreamNotFoundException" /> public static IEventStream OpenStream(this IStoreEvents storeEvents, string bucketId, Guid streamId, int minRevision = int.MinValue, int maxRevision = int.MaxValue) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.OpenStream(bucketId, streamId.ToString(), minRevision, maxRevision)); }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="bucketId">The value which uniquely identifies bucket the stream belongs to.</param> /// <param name="streamId">The value which uniquely identifies the stream within the bucket to be created.</param> /// <param name="cancellationToken"></param> /// <returns>An empty stream.</returns> public static Task <IEventStream> CreateStreamAsync(this IStoreEvents storeEvents, string bucketId, Guid streamId, CancellationToken cancellationToken) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.CreateStreamAsync(bucketId, streamId.ToString(), cancellationToken)); }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream to be created.</param> /// <param name="cancellationToken"></param> /// <returns>An empty stream.</returns> public static Task <IEventStream> CreateStreamAsync(this IStoreEvents storeEvents, string streamId, CancellationToken cancellationToken) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.CreateStreamAsync(Bucket.Default, streamId, cancellationToken)); }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream to be created.</param> /// <param name="cancellationToken"></param> /// <returns>An empty stream.</returns> public static Task <IEventStream> CreateStreamAsync(this IStoreEvents storeEvents, Guid streamId, CancellationToken cancellationToken) { return(CreateStreamAsync(storeEvents, Bucket.Default, streamId, cancellationToken)); }
public ReadFromStreamBenchmarks() { _eventStore = EventStoreHelpers.WireupEventStore(); }
public PersistenceBenchmarks() { _eventStore = EventStoreHelpers.WireupEventStore(); }
/// <summary> /// Please do not dispose of <c>store</c> This implementation will take care of its disposal. /// </summary> /// <param name="store"></param> public NEventStoreImplementation(IStoreEvents store) { _store = store; }
/// <summary> /// Reads the stream indicated from the minimum revision specified up to the maximum revision specified or creates /// an empty stream if no commits are found and a minimum revision of zero is provided. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream from which the events will be read.</param> /// <param name="minRevision">The minimum revision of the stream to be read.</param> /// <param name="maxRevision">The maximum revision of the stream to be read.</param> /// <returns>A series of committed events represented as a stream.</returns> /// <exception cref="StorageException" /> /// <exception cref="StorageUnavailableException" /> /// <exception cref="StreamNotFoundException" /> public static IEventStream OpenStream(this IStoreEvents storeEvents, string streamId, int minRevision = int.MinValue, int maxRevision = int.MaxValue) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.OpenStream(Bucket.Default, streamId, minRevision, maxRevision)); }
public NEventStoreUnitOfWorkCommitter(IStoreEvents eventStore, ConflictsWithDelegate conflictDetector, DetermisticGuidDelegate determisticGuid) { _eventStore = eventStore; _conflictDetector = conflictDetector; _determisticGuid = determisticGuid; }
public SagaEventStoreRepository(IStoreEvents eventStore) { this.eventStore = eventStore; }
/// <summary> /// Reads the stream indicated from the minimum revision specified up to the maximum revision specified or creates /// an empty stream if no commits are found and a minimum revision of zero is provided. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream from which the events will be read.</param> /// <param name="cancellationToken"></param> /// <param name="minRevision">The minimum revision of the stream to be read.</param> /// <param name="maxRevision">The maximum revision of the stream to be read.</param> /// <returns>A series of committed events represented as a stream.</returns> /// <exception cref="StorageException" /> /// <exception cref="StorageUnavailableException" /> /// <exception cref="StreamNotFoundException" /> public static Task <IEventStream> OpenStreamAsync(this IStoreEvents storeEvents, Guid streamId, CancellationToken cancellationToken, int minRevision = int.MinValue, int maxRevision = int.MaxValue) { return(OpenStreamAsync(storeEvents, Bucket.Default, streamId, cancellationToken, minRevision, maxRevision)); }
public EventStoreAdapter(IStoreEvents eventStore) { _eventStore = eventStore; }
public NEventStoreAdapter(IStoreEvents storeEvents, IConstructAggregates aggregateFactory = null) { m_StoreEvents = storeEvents; Repository = new EventStoreRepository(storeEvents, aggregateFactory ?? new AggregateFactory(), new ConflictDetector()); }
/// <summary> /// Reads the stream indicated from the minimum revision specified up to the maximum revision specified or creates /// an empty stream if no commits are found and a minimum revision of zero is provided. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="bucketId">The value which uniquely identifies bucket the stream belongs to.</param> /// <param name="streamId">The value which uniquely identifies the stream within the bucket to be created.</param> /// <param name="cancellationToken"></param> /// <param name="minRevision">The minimum revision of the stream to be read.</param> /// <param name="maxRevision">The maximum revision of the stream to be read.</param> /// <returns>A series of committed events represented as a stream.</returns> /// <exception cref="StorageException" /> /// <exception cref="StorageUnavailableException" /> /// <exception cref="StreamNotFoundException" /> public static Task <IEventStream> OpenStreamAsync(this IStoreEvents storeEvents, string bucketId, Guid streamId, CancellationToken cancellationToken, int minRevision = int.MinValue, int maxRevision = int.MaxValue) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.OpenStreamAsync(bucketId, streamId.ToString(), minRevision, maxRevision, cancellationToken)); }
/// <summary> /// Reads the stream indicated from the minimum revision specified up to the maximum revision specified or creates /// an empty stream if no commits are found and a minimum revision of zero is provided. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream from which the events will be read.</param> /// <param name="minRevision">The minimum revision of the stream to be read.</param> /// <param name="maxRevision">The maximum revision of the stream to be read.</param> /// <returns>A series of committed events represented as a stream.</returns> /// <exception cref="StorageException" /> /// <exception cref="StorageUnavailableException" /> /// <exception cref="StreamNotFoundException" /> public static IEventStream OpenStream(this IStoreEvents storeEvents, Guid streamId, int minRevision = int.MinValue, int maxRevision = int.MaxValue) { return(OpenStream(storeEvents, Bucket.Default, streamId, minRevision, maxRevision)); }
protected override void Context() { _storeEvents = Wireup.Init().UsingInMemoryPersistence().Build(); _pollingClient = new PollingClientRx(_storeEvents.Advanced, PollingInterval); }
/// <summary> /// Creates a new stream. /// </summary> /// <param name="storeEvents">The store events instance.</param> /// <param name="streamId">The value which uniquely identifies the stream to be created.</param> /// <returns>An empty stream.</returns> public static IEventStream CreateStream(this IStoreEvents storeEvents, string streamId) { EnsureStoreEventsNotNull(storeEvents); return(storeEvents.CreateStream(Bucket.Default, streamId)); }
public IgnoreConflictResolver(IStoreEvents store, IOobWriter oobStore) { _store = store; _oobStore = oobStore; }
public EventStorageRepository(IStoreEvents storage) { this.storage = storage; }
protected override void Context() { this._storeEvents = Wireup.Init().UsingInMemoryPersistence().Build(); this._repository = new EventStoreRepository(this._storeEvents, new AggregateFactory(), new ConflictDetector()); }
public EventStoreRepository(IStoreEvents eventStore, IConstructAggregates factory, IDetectConflicts conflictDetector) { _eventStore = eventStore; _factory = factory; _conflictDetector = conflictDetector; }
public ResolveWeaklyConflictResolver(IStoreEvents eventstore, IDelayedChannel delay) { _eventstore = eventstore; _delay = delay; }
/// <summary> /// Initializes a new instance of the <see cref="Repository{TAggregateRoot}"/> class. /// </summary> /// <param name="rootFactory">The aggregate root entity factory.</param> /// <param name="unitOfWork">The unit of work to interact with.</param> /// <param name="eventStore">The event store to use.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="rootFactory"/> or <paramref name="unitOfWork"/> or <paramref name="eventStore"/> is null.</exception> public Repository(Func <TAggregateRoot> rootFactory, UnitOfWork unitOfWork, IStoreEvents eventStore) { _rootFactory = rootFactory ?? throw new ArgumentNullException(nameof(rootFactory)); _unitOfWork = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork)); _eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore)); }
public WebHistoryEndpoint(IStoreEvents es) { this.es = es; }
public void Stop() { _store.Dispose(); _store = null; }
public NEventStoreRepository(IStoreEvents eventStore, IServiceProvider serviceProvider, ILogger logger = null) : base(serviceProvider) { _eventStore = eventStore; _logger = logger ?? NullLogger.Instance; }