public static void Run()
        {
            var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });;

            var fileSystemSnapshotProvider = new FileSystemSnapshotProvider <EventCountAggregate>();

            var defaultSnapshotStrategy = new DefaultSnapshotStrategy(5);

            var eventCountActorWithSnapshot = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry>
                                              .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                              .WithReadOneStreamFromStartCache(StaticData.EntityOne,
                                                                               eventTypeProvider: eventTypeProvider,
                                                                               getMultipleStreamsCatchupCacheConfiguration: builder =>
            {
                builder.KeepAppliedEventsOnAggregate = true;
            },
                                                                               snapshotStore: fileSystemSnapshotProvider,
                                                                               snapshotStrategy: defaultSnapshotStrategy)
                                              .Build();

            var eventCountActor = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry>
                                  .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                  .WithReadOneStreamFromStartCache(StaticData.EntityOne,
                                                                   eventTypeProvider: eventTypeProvider,
                                                                   getMultipleStreamsCatchupCacheConfiguration: builder =>
            {
                builder.KeepAppliedEventsOnAggregate = true;
            })
                                  .Build();

            Do.Run(eventCountActor, eventCountActorWithSnapshot);
        }
Esempio n. 2
0
        public static void Run()
        {
            var clusterVNode = EmbeddedVNodeBuilder
                               .AsSingleNode()
                               .RunInMemory()
                               .WithWorkerThreads(1)
                               .Build();

            clusterVNode.StartAsync(true).Wait();


            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Information()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Debug)
                         .WriteTo.Console()
                         .CreateLogger();

            var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);

            var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });;

            var eventCountActor = EventStoreEmbeddedStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry>
                                  .Create(clusterVNode, Do.GetConnectionSettings(), ActorConfiguration.Default, loggerFactory)
                                  .WithReadAllFromStartCache(
                eventTypeProvider: eventTypeProvider,
                getCatchupEventStoreCacheConfigurationBuilder: builder => builder.KeepAppliedEventsOnAggregate = true)
                                  .Build();

            Do.Run(eventCountActor);
        }
        public static void Run()
        {
            var eventCountActor = EventStoreStatelessActorBuilder <EventCountStatelessActor, DemoSystemRegistry>
                                  .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                  .WithBus <IEventStoreBus>((actor, bus) =>
            {
                actor.SubscribeFromEndToAllStreams();
            })
                                  .Build();

            Do.Run(eventCountActor);
        }
        public static void Run()
        {
            var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });;

            var eventCountActor = EventStoreStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry>
                                  .Create(StaticData.EventStoreUrl, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                  .WithReadManyStreamsFromStartCache(
                new[] { StaticData.EntityOne, StaticData.EntityTwo, StaticData.EntityThree },
                eventTypeProvider: eventTypeProvider,
                getMultipleStreamsCatchupCacheConfiguration: builder => builder.KeepAppliedEventsOnAggregate = true)
                                  .Build();


            Do.Run(eventCountActor);
        }
Esempio n. 5
0
        public static void Run()
        {
            var clusterVNode = EmbeddedVNodeBuilder
                               .AsSingleNode()
                               .RunInMemory()
                               .StartStandardProjections()
                               .WithWorkerThreads(1)
                               .Build();

            clusterVNode.StartAsync(true).Wait();

            CreateSubscriptionGroups(clusterVNode).Wait();

            var eventCountActorOne = EventStoreEmbeddedStatelessActorBuilder <EventCountStatelessActor, DemoSystemRegistry>
                                     .Create(clusterVNode, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                     .WithBus <IEventStoreBus>((actor, bus) =>
            {
                actor.SubscribeToPersistentSubscriptionStream(StaticData.PersistentStreamOne, StaticData.GroupIdOne);
            })
                                     .Build();

            var eventCountActorTwo = EventStoreEmbeddedStatelessActorBuilder <EventCountStatelessActor, DemoSystemRegistry>
                                     .Create(clusterVNode, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                     .WithBus <IEventStoreBus>((actor, bus) =>
            {
                actor.SubscribeToPersistentSubscriptionStream(StaticData.PersistentStreamOne, StaticData.GroupIdOne);
            })
                                     .Build();

            var position = 0;

            while (true)
            {
                if (position == 0)
                {
                    Console.WriteLine("Press enter to generate random event...");
                }

                Console.ReadLine();

                Console.WriteLine($"Generating {nameof(EventCountOne)} for stream {StaticData.PersistentStreamOne}");
                eventCountActorOne.EmitEventStore(new EventCountOne(position++, StaticData.PersistentStreamOne, Guid.NewGuid())).Wait();
            }
        }
Esempio n. 6
0
        public static void Run()
        {
            var clusterVNode = EmbeddedVNodeBuilder
                               .AsSingleNode()
                               .RunInMemory()
                               .WithWorkerThreads(1)
                               .Build();

            clusterVNode.StartAsync(true).Wait();

            var eventTypeProvider = new DefaultEventTypeProvider <EventCountAggregate>(() => new[] { typeof(EventCountOne), typeof(EventCountTwo) });;

            var eventCountActor = EventStoreEmbeddedStatefulActorBuilder <EventCountStatefulActor, EventCountAggregate, DemoSystemRegistry>
                                  .Create(clusterVNode, Do.GetConnectionSettings(), ActorConfiguration.Default)
                                  .WithReadAllFromEndCache(
                eventTypeProvider: eventTypeProvider,
                getSubscribeFromEndCacheConfiguration: builder => builder.KeepAppliedEventsOnAggregate = true)
                                  .Build();

            Do.Run(eventCountActor);
        }