public void Setup() { unitOfWorkDomainEventHandler1 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>(); unitOfWorkDomainEventHandler2 = Substitute.For<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>(); unitOfWorkDomainEventHandlers = new List<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>> { unitOfWorkDomainEventHandler1, unitOfWorkDomainEventHandler2 }; domainEventHandler3 = Substitute.For<IDomainEventHandler<TestDomainEvent>>(); domainEventHandler4 = Substitute.For<IDomainEventHandler<TestDomainEvent>>(); domainEventHandlers = new List<IDomainEventHandler<TestDomainEvent>> { domainEventHandler3, domainEventHandler4 }; eventHandlerResolver = Substitute.For<IDomainEventHandlerResolver>(); unitOfWorkEventHandlerResolver = Substitute.For<IUnitOfWorkDomainEventHandlerResolver>(); unitOfWork = Substitute.For<TestUnitOfWork>(); domainEvent = new TestDomainEvent(Guid.NewGuid()); unitOfWorkEventHandlerResolver.ResolveEventHandlers<IUnitOfWorkDomainEventHandler<TestDomainEvent, TestUnitOfWork>>().Returns(unitOfWorkDomainEventHandlers); eventHandlerResolver.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>().Returns(domainEventHandlers); sut = new TestUnitOfWorkDomainRepository(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork); }
public void Setup() { unitOfWorkDomainEventHandler1 = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >(); unitOfWorkDomainEventHandler2 = Substitute.For <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >(); unitOfWorkDomainEventHandlers = new List <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> > { unitOfWorkDomainEventHandler1, unitOfWorkDomainEventHandler2 }; domainEventHandler3 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); domainEventHandler4 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); domainEventHandlers = new List <IDomainEventHandler <TestDomainEvent> > { domainEventHandler3, domainEventHandler4 }; eventHandlerResolver = Substitute.For <IDomainEventHandlerResolver>(); unitOfWorkEventHandlerResolver = Substitute.For <IUnitOfWorkDomainEventHandlerResolver>(); unitOfWork = Substitute.For <TestUnitOfWork>(); domainEvent = new TestDomainEvent(Guid.NewGuid()); unitOfWorkEventHandlerResolver.ResolveEventHandlers <IUnitOfWorkDomainEventHandler <TestDomainEvent, TestUnitOfWork> >().Returns(unitOfWorkDomainEventHandlers); eventHandlerResolver.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >().Returns(domainEventHandlers); sut = new TestUnitOfWorkDomainRepository(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork); }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionWorker"/> class. /// </summary> /// <param name="loggerFactory">The logger factory.</param> /// <param name="env">The env.</param> /// <param name="domainEventHandlerResolver">The domain event handler resolver.</param> /// <param name="persistentSubscriptionsClient">The persistent subscriptions client.</param> /// <param name="httpClient">The HTTP client.</param> public SubscriptionWorker(IDomainEventHandlerResolver domainEventHandlerResolver, EventStorePersistentSubscriptionsClient persistentSubscriptionsClient, HttpClient httpClient) { this.DomainEventHandlerResolver = domainEventHandlerResolver; this.PersistentSubscriptionsClient = persistentSubscriptionsClient; this.HttpClient = httpClient; }
/// <summary> /// Initializes a new instance of the <see cref="DomainEventBroker"/> class. /// </summary> /// <param name="eventHandlerResolver">Event handler resolver instance for finding domain event handlers.</param> public DomainEventBroker(IDomainEventHandlerResolver eventHandlerResolver) { if (eventHandlerResolver == null) { throw new ArgumentNullException("eventHandlerResolver"); } this.eventHandlerResolver = eventHandlerResolver; }
/// <summary> /// Initializes a new instance of the <see cref="CompositeUnitOfWorkDomainRepository{TUnitOfWork, TAggregateRoot1, TAggregateRoot2}"/> class. /// </summary> /// <param name="eventHandlerResolver">Event handler resolver for finding domain event handlers.</param> /// <param name="unitOfWorkEventHandlerResolver">Event handler resolver for finding unit-of-work domain event handlers.</param> /// <param name="unitOfWork">The Unit of Work context instance.</param> protected CompositeUnitOfWorkDomainRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, TUnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); } this.unitOfWork = unitOfWork; immediateEventBroker = new DomainEventBroker(eventHandlerResolver); unitOfWorkDomainEventBroker = new UnitOfWorkDomainEventBroker <TUnitOfWork>(unitOfWorkEventHandlerResolver, unitOfWork); }
/// <summary> /// Initializes a new instance of the <see cref="PersistentSubscription"/> class. /// </summary> /// <param name="persistentSubscriptionsClient">The persistent subscriptions client.</param> /// <param name="persistentSubscriptionDetails">The persistent subscription details.</param> /// <param name="domainEventHandlerResolver">The domain event handler resolver.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> private PersistentSubscription(EventStorePersistentSubscriptionsClient persistentSubscriptionsClient, PersistentSubscriptionDetails persistentSubscriptionDetails, IDomainEventHandlerResolver domainEventHandlerResolver, String username, String password) { this.PersistentSubscriptionDetails = persistentSubscriptionDetails; this.PersistentSubscriptionsClient = persistentSubscriptionsClient; this.DomainEventHandlerResolver = domainEventHandlerResolver; this.UserCredentials = new UserCredentials(username, password); }
public void Setup() { domainEventHandler1 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); domainEventHandler2 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); IEnumerable <IDomainEventHandler <TestDomainEvent> > eventHandlers = new List <IDomainEventHandler <TestDomainEvent> > { domainEventHandler1, domainEventHandler2 }; domainEvent = new TestDomainEvent(Guid.NewGuid()); eventHandlerResolver = Substitute.For <IDomainEventHandlerResolver>(); eventHandlerResolver.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >().Returns(eventHandlers); sut = new TestDomainRepository(eventHandlerResolver); }
public void Setup() { domainEventHandler1 = Substitute.For<IAsyncDomainEventHandler<TestDomainEvent>>(); domainEventHandler2 = Substitute.For<IAsyncDomainEventHandler<TestDomainEvent>>(); IEnumerable<IAsyncDomainEventHandler<TestDomainEvent>> eventHandlers = new List<IAsyncDomainEventHandler<TestDomainEvent>> { domainEventHandler1, domainEventHandler2 }; domainEvent = new TestDomainEvent(Guid.NewGuid()); eventHandlerResolver = Substitute.For<IDomainEventHandlerResolver>(); eventHandlerResolver.ResolveEventHandlers<IAsyncDomainEventHandler<TestDomainEvent>>().Returns(eventHandlers); sut = new TestAsyncDomainRepository(eventHandlerResolver); }
public static IHostBuilder CreateHostBuilder(string[] args) { Console.Title = "Messaging Service"; //At this stage, we only need our hosting file for ip and ports IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("hosting.json", optional: true) .AddJsonFile("hosting.development.json", optional: true) .AddEnvironmentVariables().Build(); IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args); hostBuilder.ConfigureLogging(logging => { logging.AddConsole(); }).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); webBuilder.UseConfiguration(config); webBuilder.UseKestrel(); }) .ConfigureServices(services => { RequestSentToEmailProviderEvent e = new RequestSentToEmailProviderEvent(Guid.Parse("2AA2D43B-5E24-4327-8029-1135B20F35CE"), "", new List <String>(), "", "", true); RequestSentToSMSProviderEvent s = new RequestSentToSMSProviderEvent(Guid.NewGuid(), "", "", ""); TypeProvider.LoadDomainEventsTypeDynamically(); services.AddHostedService <SubscriptionWorker>(provider => { IDomainEventHandlerResolver r = provider.GetRequiredService <IDomainEventHandlerResolver>(); EventStorePersistentSubscriptionsClient p = provider.GetRequiredService <EventStorePersistentSubscriptionsClient>(); HttpClient h = provider.GetRequiredService <HttpClient>(); SubscriptionWorker worker = new SubscriptionWorker(r, p, h); worker.TraceGenerated += Worker_TraceGenerated; return(worker); }); }); return(hostBuilder); }
public void Setup() { domainEventHandler1 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); domainEventHandler2 = Substitute.For <IDomainEventHandler <TestDomainEvent> >(); domainEventHandler3 = Substitute.For <IDomainEventHandler <AnotherTestDomainEvent> >(); asyncDomainEventHandler1 = Substitute.For <IAsyncDomainEventHandler <TestDomainEvent> >(); asyncDomainEventHandler2 = Substitute.For <IAsyncDomainEventHandler <TestDomainEvent> >(); asyncDomainEventHandler3 = Substitute.For <IAsyncDomainEventHandler <AnotherTestDomainEvent> >(); resolver = Substitute.For <IDomainEventHandlerResolver>(); resolver.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >().Returns(new[] { domainEventHandler1, domainEventHandler2 }); resolver.ResolveEventHandlers <IDomainEventHandler <TestDomainEvent> >().Returns(new[] { domainEventHandler1, domainEventHandler2 }); resolver.ResolveEventHandlers <IDomainEventHandler <AnotherTestDomainEvent> >().Returns(new[] { domainEventHandler3 }); resolver.ResolveEventHandlers <IAsyncDomainEventHandler <TestDomainEvent> >().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 }); resolver.ResolveEventHandlers <IAsyncDomainEventHandler <TestDomainEvent> >().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 }); resolver.ResolveEventHandlers <IAsyncDomainEventHandler <AnotherTestDomainEvent> >().Returns(new[] { asyncDomainEventHandler3 }); sut = new DomainEventBroker(resolver); }
public void Setup() { domainEventHandler1 = Substitute.For<IDomainEventHandler<TestDomainEvent>>(); domainEventHandler2 = Substitute.For<IDomainEventHandler<TestDomainEvent>>(); domainEventHandler3 = Substitute.For<IDomainEventHandler<AnotherTestDomainEvent>>(); asyncDomainEventHandler1 = Substitute.For<IAsyncDomainEventHandler<TestDomainEvent>>(); asyncDomainEventHandler2 = Substitute.For<IAsyncDomainEventHandler<TestDomainEvent>>(); asyncDomainEventHandler3 = Substitute.For<IAsyncDomainEventHandler<AnotherTestDomainEvent>>(); resolver = Substitute.For<IDomainEventHandlerResolver>(); resolver.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>().Returns(new[] { domainEventHandler1, domainEventHandler2 }); resolver.ResolveEventHandlers<IDomainEventHandler<TestDomainEvent>>().Returns(new[] { domainEventHandler1, domainEventHandler2 }); resolver.ResolveEventHandlers<IDomainEventHandler<AnotherTestDomainEvent>>().Returns(new[] { domainEventHandler3 }); resolver.ResolveEventHandlers<IAsyncDomainEventHandler<TestDomainEvent>>().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 }); resolver.ResolveEventHandlers<IAsyncDomainEventHandler<TestDomainEvent>>().Returns(new[] { asyncDomainEventHandler1, asyncDomainEventHandler2 }); resolver.ResolveEventHandlers<IAsyncDomainEventHandler<AnotherTestDomainEvent>>().Returns(new[] { asyncDomainEventHandler3 }); sut = new DomainEventBroker(resolver); }
private PersistentSubscription(IPersistentSubscriptionsClient persistentSubscriptionsClient, PersistentSubscriptionDetails persistentSubscriptionDetails, IDomainEventHandlerResolver domainEventHandlerResolver, String username, String password) { this.PersistentSubscriptionsClient = persistentSubscriptionsClient; this.PersistentSubscriptionDetails = persistentSubscriptionDetails; UserCredentials userCredentials = new(username, password); Func <global::EventStore.Client.PersistentSubscription, ResolvedEvent, Int32?, CancellationToken, Task> eventAppeared = (ps, re, retryCount, ct) => PersistentSubscription.EventAppeared(ps, re, retryCount, domainEventHandlerResolver, ct); this.Subscribe = ct => persistentSubscriptionsClient.SubscribeAsync(this.PersistentSubscriptionDetails.StreamName, this.PersistentSubscriptionDetails.GroupName, eventAppeared, this.SubscriptionDropped, userCredentials, persistentSubscriptionDetails.InflightMessages, ct); }
public TestDomainRepository(IDomainEventHandlerResolver eventHandlerResolver) : base(eventHandlerResolver) { }
/// <summary> /// Initializes a new instance of the <see cref="DomainEventController"/> class. /// </summary> /// <param name="domainEventHandlerResolver">The domain event handler resolver.</param> public DomainEventController(IDomainEventHandlerResolver domainEventHandlerResolver) { this.DomainEventHandlerResolver = domainEventHandlerResolver; }
public TestUnitOfWorkDomainRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, TestUnitOfWork unitOfWork) : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork) { }
public InternalCompositeRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, InternalUnitOfWork unitOfWork) : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork) { }
public InternalAsyncDomainRepository(IDomainEventHandlerResolver eventHandlerResolver) : base(eventHandlerResolver) { }
/// <summary> /// Initializes a new instance of the <see cref="DomainRepository{TAggregate}"/> class. /// </summary> /// <param name="eventHandlerResolver">Event handler resolver for finding domain event handlers.</param> protected DomainRepository(IDomainEventHandlerResolver eventHandlerResolver) : base(new DomainEventBroker(eventHandlerResolver)) { }
public AuditTrailEntryDomainRepository(IDomainEventHandlerResolver eventHandlerResolver, IUnitOfWorkDomainEventHandlerResolver unitOfWorkEventHandlerResolver, IDbContext unitOfWork) : base(eventHandlerResolver, unitOfWorkEventHandlerResolver, unitOfWork) { }
public static PersistentSubscription Create(IPersistentSubscriptionsClient persistentSubscriptionsClient, PersistentSubscriptionDetails persistentSubscriptionDetails, IDomainEventHandlerResolver domainEventHandlerResolver, String username = "******", String password = "******") => new(persistentSubscriptionsClient, persistentSubscriptionDetails, domainEventHandlerResolver, username, password);