public AutofacDomainEventDispatcher(IDomainEventStore domainEventStore, IComponentContext componentContext) { if (domainEventStore == null) throw new ArgumentNullException("domainEventStore"); if (componentContext == null) throw new ArgumentNullException("componentContext"); _domainEventStore = domainEventStore; _componentContext = componentContext; }
public SnapshotRepository(ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy, IDomainRepository domainRepository, IDomainEventStore domainEventStore) { if (snapshotStore == null) { throw new ArgumentNullException("snapshotStore"); } if (snapshotStrategy == null) { throw new ArgumentNullException("snapshotStrategy"); } if (domainRepository == null) { throw new ArgumentNullException("domainRepository"); } if (domainEventStore == null) { throw new ArgumentNullException("domainEventStore"); } _snapshotStore = snapshotStore; _snapshotStrategy = snapshotStrategy; _domainRepository = domainRepository; _domainEventStore = domainEventStore; }
public AnnouncementPreferencesDeletionCompletedIntegrationEventFailureHandler(ILogger logger, IDomainEventStore domainEventStore, IUserRepository userRepository, IIntegrationEventBus integrationEventBus) { _logger = logger; _domainEventStore = domainEventStore; _userRepository = userRepository; _integrationEventBus = integrationEventBus; }
public UserDeletionCompletedIntegrationEventFailureHandler(ILogger logger, IIntegrationEventBus integrationEventBus, IDomainEventStore domainEventStore, IAccountRepository accountRepository) { _logger = logger; _integrationEventBus = integrationEventBus; _domainEventStore = domainEventStore; _accountRepository = accountRepository; }
/// <summary> /// Mark single domain event as processed. /// Redirects call to the collection API. /// </summary> /// <typeparam name="TEvent">domain event type</typeparam> /// <param name="store">domain event store</param> /// <param name="domainEvent">mark domain event as processed</param> public static void Mark <TEvent>(this IDomainEventStore <TEvent> store, TEvent domainEvent) where TEvent : IDomainEvent { Contract.Requires(store != null); Contract.Requires(domainEvent != null); Contract.Requires(domainEvent.ProcessedAt == null); store.Mark(new[] { domainEvent.URI }); }
public RemoveLikeRequestHandler( IOptions <AggregatesConfig> cacheConfig, IMemoryCache memoryCache, IDomainEventDispatcher <LikesId> domainEventsDispatcher, IAggregateSnapshotAccessor <Likes, LikesId> snapshotAccessor, IDomainEventStore <LikesId> eventsAccessor) : base(cacheConfig, memoryCache, domainEventsDispatcher, snapshotAccessor, eventsAccessor) { }
public SchemeUnpublishRequestHandler( IOptions <AggregatesConfig> cacheConfig, IMemoryCache memoryCache, IDomainEventDispatcher <PublicSchemeId> domainEventsDispatcher, IAggregateSnapshotAccessor <PublicScheme, PublicSchemeId> schemesSnapshot, IDomainEventStore <PublicSchemeId> eventsAccessor) : base(cacheConfig, memoryCache, domainEventsDispatcher, schemesSnapshot, eventsAccessor) { }
/// <summary> /// Constructor. /// </summary> /// <param name="domainEventStore">Decorated domain event store.</param> /// <param name="publisher">Event publisher.</param> public PublishingDomainEventStore(IDomainEventStore <TAggregate, TAggregateId> domainEventStore, IEventPublisher publisher) { _domainEventStore = domainEventStore; _publisher = publisher; // Subscribe to any errors in publishing. _publisher.OnError += (e, ex) => { OnPublishError((IDomainEvent)e, ex); }; }
public void MergeInto(IDomainEventStore domainEventStore) { if (_mergedStore != null) throw new InvalidOperationException("This store has already been merged with another store."); var domainEventsToMerge = RetrieveAndClear(); _mergedStore = domainEventStore; foreach (var domainEvent in domainEventsToMerge) _mergedStore.Add(domainEvent); }
public TOutput Submit <TInput, TOutput>( ISerialization <TInput> input, ISerialization <TOutput> output, IServiceLocator locator, IDomainEventStore domainStore, bool returnInstance, TInput data) { TEvent domainEvent; try { domainEvent = data != null?input.Deserialize <TInput, TEvent>(data, locator) : Activator.CreateInstance <TEvent>(); } catch (Exception ex) { throw new ArgumentException("Error deserializing domain event.", ex); } string uri; try { uri = domainStore.Submit(domainEvent); } catch (SecurityException) { throw; } catch (Exception ex) { throw new ArgumentException( ex.Message, data == null ? new FrameworkException("Error while submitting event: {0}. Data not sent.".With(ex.Message), ex) : new FrameworkException(@"Error while submitting event: {0}. Sent data: {1}".With(ex.Message, input.Serialize(domainEvent)), ex)); } try { if (returnInstance) { return(output.Serialize(domainEvent)); } else { return(output.Serialize(uri)); } } catch (Exception ex) { throw new ArgumentException( ex.Message, new FrameworkException(@"Error serializing result: " + ex.Message, ex)); } }
protected DomainRequestHandler( IOptions <AggregatesConfig> aggConfig, IMemoryCache memoryCache, IDomainEventDispatcher <TAggregateId> eventsDispatcher, IAggregateSnapshotAccessor <TAggregate, TAggregateId> aggregateSnapshot, IDomainEventStore <TAggregateId> eventsAccessor) { this.aggregatesConfig = aggConfig; this.memoryCache = memoryCache; this.eventsDispatcher = eventsDispatcher; this.aggregateSnapshotAccessor = aggregateSnapshot; this.eventStrore = eventsAccessor; }
/// <summary> /// Submit single domain event to the store. /// Redirects call to the collection API. /// </summary> /// <typeparam name="TEvent">domain event type</typeparam> /// <param name="store">domain event store</param> /// <param name="domainEvent">raise domain event</param> /// <returns>event identifier</returns> public static string Submit <TEvent>(this IDomainEventStore <TEvent> store, TEvent domainEvent) where TEvent : IDomainEvent { Contract.Requires(store != null); Contract.Requires(domainEvent != null); var uris = store.Submit(new[] { domainEvent }); if (uris != null && uris.Length == 1) { return(uris[0]); } return(null); }
public SubmitEvent( IDomainEventStore eventStore, IServiceLocator locator, IDomainModel domainModel, IPermissionManager permissions) { Contract.Requires(eventStore != null); Contract.Requires(locator != null); Contract.Requires(domainModel != null); Contract.Requires(permissions != null); this.EventStore = eventStore; this.Locator = locator; this.DomainModel = domainModel; this.Permissions = permissions; }
public static Task <TAggregate> Submit <TEvent, TAggregate>(this IDomainEventStore store, TEvent domainEvent, TAggregate aggregate) where TEvent : class, IDomainEvent <TAggregate> where TAggregate : class, IAggregateRoot { if (store == null) { throw new ArgumentNullException("store can't be null"); } if (domainEvent == null) { throw new ArgumentNullException("domainEvent can't be null"); } if (aggregate == null) { throw new ArgumentNullException("aggregate can't be null"); } return(store.Submit <TEvent, TAggregate>(domainEvent, aggregate.URI)); }
public TOutput Submit <TInput, TOutput>( ISerialization <TInput> input, ISerialization <TOutput> output, IServiceLocator locator, IDomainEventStore domainStore, string uri, TInput data) { TEvent domainEvent; try { domainEvent = data != null?input.Deserialize <TInput, TEvent>(data, locator) : Activator.CreateInstance <TEvent>(); } catch (Exception ex) { throw new ArgumentException("Error deserializing domain event.", ex); } var repository = locator.Resolve <IRepository <TAggregate> >(); var aggregate = repository.Find(uri); if (aggregate == null) { throw new ArgumentException("Can't find aggregate with Uri: {0}".With(uri)); } try { domainEvent.Apply(aggregate); } catch (SecurityException) { throw; } catch (Exception ex) { throw new ArgumentException(ex.Message, ex); } try { domainStore.Submit(domainEvent); } catch (SecurityException) { throw; } catch (Exception ex) { throw new ArgumentException( ex.Message, data == null ? new FrameworkException("Error while submitting event: {0}. Data not sent.".With(ex.Message), ex) : new FrameworkException(@"Error while submitting event: {0}. Sent data: {1}".With(ex.Message, output.Serialize(domainEvent)), ex)); } return(output.Serialize(aggregate)); }
public void Should_Append_To_Domain_Event_Store() { IDomainEventStore <TestAggregate, Guid> eventStore = Factory.CreateEventStore <TestAggregate, Guid>(); // Create aggregate. TestAggregate aggregate = new TestAggregate(Guid.NewGuid()); eventStore.Save(aggregate); IDomainEventStream <Guid> stream = eventStore.GetDomainEventStream(aggregate.Id); var fromStream = new TestAggregate(stream); Assert.NotNull(stream); Assert.Equal(aggregate.Id, fromStream.Id); // 1 domain event in total: Created event. Assert.Equal(1, stream.DomainEventCount); }
public void Should_Retrieve_Aggregate_Stream() { IDomainEventStore <TestAggregate, Guid> eventStore = Factory.CreateEventStore <TestAggregate, Guid>(); // Create and modify aggregate. TestAggregate aggregate = new TestAggregate(Guid.NewGuid()); aggregate.ExecuteSomeOperation("I was modified!~"); eventStore.Save(aggregate); IDomainEventStream <Guid> stream = eventStore.GetDomainEventStream(aggregate.Id); Assert.NotNull(stream); Assert.Equal(aggregate.Id, stream.AggregateId); // 2 domain events in total: Created + Modified events. Assert.Equal(2, stream.DomainEventCount); // Stream starts from version 1 to 2. Assert.Equal(1, stream.BeginVersion); Assert.Equal(2, stream.EndVersion); }
public UserRoomForRentAnnouncementPreferenceChangedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public AccountConfirmedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public AddedToFavoritesEventHandler(IDomainEventStore <FavoritesId> eventStore) : base(eventStore) { }
public UserAnnouncementPreferenceLimitChangedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public RemovedFromFavoritesEventHandler(IDomainEventStore <FavoritesId> eventStore) : base(eventStore) { }
public UserDeletedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public EventSourcedDomainEventHandler(IDomainEventStore <TAggregateId> domainEventAccessor) { this.domainEventAccessor = domainEventAccessor; }
public SchemeUnpublishedEventHandler(IDomainEventStore <PublicSchemeId> domainEventAccessor) : base(domainEventAccessor) { }
public DbContextSupportingDomainEvents(DbContextOptions options, IDomainEventStore domainEventStore) : base(options) { _domainEventStore = domainEventStore; }
public TestAggregateRepository(IDomainEventStore <TestAggregate, Guid> eventStore) { DomainEventStore = eventStore; }
public LikeAddedEventHandler(IDomainEventStore <LikesId> eventStore) : base(eventStore) { }
public NHibernateDomainEventListener(IDomainEventStore domainEventStore) { if (domainEventStore == null) throw new ArgumentNullException("domainEventStore"); _domainEventStore = domainEventStore; }
public AccountLoggedInDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public AccountRoleDeletedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public AccountTokenGeneratedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
public UserServiceActiveChangedDomainEventHandler(IDomainEventStore domainEventStore) { _domainEventStore = domainEventStore; }
void IGenerateDomainEvents.SetEventStore(IDomainEventStore domainEventStore) { _domainEventStore.MergeInto(domainEventStore); }