public static World AddWorld(this IServiceCollection services,
                                     ClusterVNode clusterVNode,
                                     ConnectionSettings connectionSettings,
                                     Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null)
        {
            var eventStoreConnection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings);

            services.AddSingleton <IConnectionStatusMonitor <IEventStoreConnection>, EventStoreConnectionStatusMonitor>();
            services.AddSingleton(eventStoreConnection);
            services.AddSingleton(connectionSettings);

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            services.AddSingleton <IEventStoreRepositoryConfiguration>(eventStoreRepositoryConfiguration);

            services.AddTransient <IEventStoreRepository, EventStoreRepository>();

            var world = new World(services, true);

            services.AddSingleton(world);

            return(world);
        }
Beispiel #2
0
        public static EventStoreStatelessActorBuilder <TActor, TRegistry> Create(
            ClusterVNode clusterVNode,
            ConnectionSettings connectionSettings,
            IActorConfiguration actorConfiguration,
            ILoggerFactory?loggerFactory = null,
            Action <IEventStoreRepositoryConfiguration>?getEventStoreRepositoryConfiguration = null)

        {
            var connection = EmbeddedEventStoreConnection.Create(clusterVNode, connectionSettings);

            loggerFactory ??= new DummyLoggerFactory();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            var connectionStatusMonitor = new EventStoreConnectionStatusMonitor(connection, loggerFactory);

            var eventStoreRepository = new EventStoreRepository(
                eventStoreRepositoryConfiguration,
                connection,
                connectionStatusMonitor,
                loggerFactory);

            var eventStoreStatelessActorBuilder = new EventStoreStatelessActorBuilder <TActor, TRegistry>(actorConfiguration, eventStoreRepository, connectionStatusMonitor, loggerFactory);

            return(eventStoreStatelessActorBuilder);
        }
Beispiel #3
0
        public static World AddWorld(this IServiceCollection services,
                                     string eventStoreConnectionString,
                                     ConnectionSettingsBuilder connectionSettingsBuilder,
                                     Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null)
        {
            var eventStoreConnection = EventStoreConnection.Create(eventStoreConnectionString, connectionSettingsBuilder);

            var connectionSettings = connectionSettingsBuilder.Build();

            services.AddSingleton <IConnectionStatusMonitor <IEventStoreConnection>, EventStoreConnectionStatusMonitor>();
            services.AddSingleton(eventStoreConnection);
            services.AddSingleton(connectionSettings);

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration);

            services.AddSingleton <IEventStoreRepositoryConfiguration>(eventStoreRepositoryConfiguration);

            services.AddTransient <IEventStoreRepository, EventStoreRepository>();

            var world = new World(services, true);

            services.AddSingleton(world);

            return(world);
        }
Beispiel #4
0
        public async Task ShouldRegisterOneBusAndHandleEventsFromDifferentSources()
        {
            var testBusRegistrationActor = EventStoreEmbeddedStatelessActorBuilder <TestBusRegistrationStatelessActor, DummyBusRegistry>
                                           .Create(_clusterVNode, _connectionSettings, ActorConfiguration.Default, _loggerFactory)
                                           .WithBus <IEventStoreBus>((actor, bus) => actor.SubscribeFromEndToAllStreams())
                                           .WithBus <IDummyBus>((actor, bus) =>
            {
                actor.SubscribeDummyBus("somesubject");
            })
                                           .Build();

            await Task.Delay(500);

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();
            var connection        = EmbeddedEventStoreConnection.Create(_clusterVNode, _connectionSettings);
            var connectionMonitor = new EventStoreConnectionStatusMonitor(connection, _loggerFactory);

            var eventStoreRepository = new EventStoreAggregateRepository(
                eventStoreRepositoryConfiguration,
                connection,
                connectionMonitor,
                _loggerFactory);


            var dummyBus = testBusRegistrationActor.GetConnectedBus <IDummyBus>();

            dummyBus.Push(new SomeData("entity", Guid.NewGuid()));

            await eventStoreRepository.Emit(new SomeData("thisisit", Guid.NewGuid()));

            await Task.Delay(500);

            Assert.AreEqual(2, testBusRegistrationActor.Events.Count);
            Assert.True(testBusRegistrationActor.Events.Any(ev => ev.EntityId == "thisisit"));

            testBusRegistrationActor.Dispose();
        }
        private static EventStoreStatelessActorBuilder <TActor, TRegistry> CreateInternal(
            IActorConfiguration actorConfiguration,
            IEventStoreConnection eventStoreConnection,
            ILoggerFactory loggerFactory = null,
            Action <IEventStoreRepositoryConfiguration> eventStoreRepositoryConfigurationBuilder = null)
        {
            loggerFactory ??= new DummyLoggerFactory();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            eventStoreRepositoryConfigurationBuilder?.Invoke(eventStoreRepositoryConfiguration);

            var connectionMonitor = new EventStoreConnectionStatusMonitor(eventStoreConnection, loggerFactory);

            var eventStoreRepository = new EventStoreAggregateRepository(
                eventStoreRepositoryConfiguration,
                eventStoreConnection,
                connectionMonitor,
                loggerFactory);

            var builder = new EventStoreStatelessActorBuilder <TActor, TRegistry>(actorConfiguration, eventStoreRepository, connectionMonitor, loggerFactory);

            return(builder);
        }
Beispiel #6
0
        public async Task ShouldBuildAndRunActors()
        {
            var connection        = EmbeddedEventStoreConnection.Create(_clusterVNode, _connectionSettings);
            var connectionMonitor = new EventStoreConnectionStatusMonitor(connection, _loggerFactory);

            var eventProvider = new ConsumerBasedEventProvider <TestActorAutoBuildOne>();

            var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration();

            var actorConfiguration = new ActorConfiguration();

            var eventStoreRepository = new EventStoreRepository(
                eventStoreRepositoryConfiguration,
                connection,
                connectionMonitor,
                _loggerFactory);

            var persistentEventStoreStreamConfiguration = new PersistentSubscriptionEventStoreStreamConfiguration(_streamId, _groupIdOne, _userCredentials);

            var persistentSubscriptionEventStoreStream = new PersistentSubscriptionEventStoreStream(
                connectionMonitor,
                persistentEventStoreStreamConfiguration,
                eventProvider,
                _loggerFactory);

            var volatileEventStoreStreamConfiguration = new SubscribeFromEndEventStoreStreamConfiguration(_userCredentials);

            var volatileEventStoreStream = new SubscribeFromEndToAllEventStoreStream(
                connectionMonitor,
                volatileEventStoreStreamConfiguration,
                eventProvider,
                _loggerFactory);

            await Task.Delay(1000);

            var eventStoreBus = new EventStoreBus(connectionMonitor, eventStoreRepository);

            var testActorAutoBuildOne = new TestActorAutoBuildOne(actorConfiguration, _loggerFactory);
            await testActorAutoBuildOne.ConnectTo(eventStoreBus);

            var testActorAutoBuildTwo = new TestActorAutoBuildOne(actorConfiguration, _loggerFactory);
            await testActorAutoBuildTwo.ConnectTo(eventStoreBus);

            testActorAutoBuildOne.SubscribeToEventStream(persistentSubscriptionEventStoreStream);
            testActorAutoBuildOne.SubscribeToEventStream(volatileEventStoreStream);

            await Task.Delay(2000);

            await testActorAutoBuildTwo.EmitEventStore(new SomeMoreData(_correlationId, "some-stream"));

            await Task.Delay(1000);

            Assert.AreEqual(1, testActorAutoBuildOne.Events.Count);

            await testActorAutoBuildTwo.EmitEventStore(new SomeMoreData(_correlationId, _streamId));

            await Task.Delay(100);

            Assert.AreEqual(3, testActorAutoBuildOne.Events.Count);

            eventStoreBus.Dispose();
            testActorAutoBuildOne.Dispose();
            testActorAutoBuildTwo.Dispose();
        }
Beispiel #7
0
 public CcyPairGrain(EventStoreRepositoryConfiguration eventStoreConfiguration) : base(eventStoreConfiguration)
 {
 }