コード例 #1
0
ファイル: Startup.cs プロジェクト: Nangal/ddd-actors-talk
        public void ConfigureServices(IServiceCollection services)
        {
            PrometheusMetrics.TryConfigure(Environment.ApplicationName);
            EventMapping.Map();

            var esConnection = ConfigureEsConnection(
                Configuration["EventStore:ConnectionString"],
                Environment.ApplicationName);
            var documentStore = ConfigureRavenDb(
                Configuration["RavenDb:Server"],
                Configuration["RavenDb:Database"]
                );

            var ravenDbStore = new RavenDBProvider(documentStore);

            services.AddSingleton(c => (Func <IAsyncDocumentSession>)GetSession);
            services.AddSingleton <IHostedService>(
                new EventStoreService(
                    esConnection,
                    Props.FromProducer(() =>
                                       new SubscriptionActor(
                                           esConnection,
                                           new RavenDbCheckpointStore(GetSession, "readmodels"),
                                           "ravenDbSubscription",
                                           (Props.FromProducer(
                                                () => new CustomerVehiclesProjection(ravenDbStore)), "customerVehicles"),
                                           (Props.FromProducer(
                                                () => new VehicleItemProjection(ravenDbStore)), "vehicleItems")
                                           )
                                       )
                    )
                );

            IAsyncDocumentSession GetSession() => documentStore.OpenAsyncSession();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: Nangal/ddd-actors-talk
        public void ConfigureServices(IServiceCollection services)
        {
            PrometheusMetrics.TryConfigure(Environment.ApplicationName);
            MapEvents();

            var esConnection = ConfigureEsConnection(
                Configuration["EventStore:ConnectionString"],
                Environment.ApplicationName);

            var store =
                new MeasuredStore(
                    new AggregateStore(esConnection));

            var customerService = new CustomerCommandService(store);

            var bus =
                MassTransitConfiguration.ConfigureBus(
                    "rabbitmq://localhost", "guest", "guest",
                    ("talk-customer", ep =>
            {
                ep.Handler <Messages.Customer.Commands.RegisterCustomer>(
                    ctx => customerService.Handle(ctx.Message));
            }));

            services.AddMassTransit(bus);

            var reactorsSubscriptionManager = new SubscriptionManager(
                esConnection,
                new EsCheckpointStore(esConnection, "reactors-checkpoint"),
                "commandsReactors",
                ConfigureReactors()
                );

            services.AddSingleton <IHostedService>(
                new EventStoreService(
                    esConnection,
                    reactorsSubscriptionManager)
                );

            Log.SetLoggerFactory(LoggerFactory);
            services.AddSingleton <IHostedService>(provider =>
                                                   new ProtoClusterHostedService(
                                                       new Uri(Configuration["Proto:ConsulUrl"]),
                                                       Configuration["Proto:ClusterName"],
                                                       "localhost",
                                                       Configuration.GetValue <int>("Proto:NodePort"),
                                                       esConnection));
        }