Ejemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, EventProjector projector, IHostApplicationLifetime applicationLifeTime)
        {
            //app.UseHttpsRedirection();             //app.UseAuthorization();
            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseSwagger();
            app.UseSwaggerUI(c =>      //Swagger UI should be served from static container not service
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", $"Inventory View Service {env.EnvironmentName}");
            });

            // if using a DB make the projection / writer a 3rd generic host service.
            redisMultiplexer !.ConnectionFailed += (sender, args) => applicationLifeTime.StopApplication();
            this.subscriber = new EventSubscriber(() => redisMultiplexer !.GetDatabase(), projector.ProjectBatch, applicationLifeTime, app.ApplicationServices.GetRequiredService <ILogger <EventSubscriber> >());
            this.subscriber.Start();
        }
Ejemplo n.º 2
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, EventProjector projector, IHostApplicationLifetime applicationLifeTime)
        {
            //app.UseHttpsRedirection();             //app.UseAuthorization();
            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseSwagger();
            app.UseSwaggerUI(c =>      //Swagger UI should be served from static container not service
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", $"Inventory View Service {env.EnvironmentName}");
            });

            // if using a DB make the projection / writer a 3rd generic host service.
            var connection = EventStoreConnection.Create(Configuration.GetConnectionString("EventStoreConnection"));

            connection.ConnectAsync().Wait();
            this.subscriber = new EventSubscriber(connection, projector.Project, applicationLifeTime, app.ApplicationServices.GetRequiredService <ILogger <EventSubscriber> >());
            this.subscriber.Start();
        }