1111using Microsoft . Extensions . Hosting ;
1212using OpenTelemetry . Trace ;
1313using Serilog ;
14+ using Shuttle . Access . Server . v1 . EventHandlers ;
1415using Shuttle . Core . Contract ;
1516using Shuttle . Core . Data ;
1617using Shuttle . Core . DependencyInjection ;
1718using Shuttle . Core . Mediator ;
19+ using Shuttle . Core . Pipelines ;
1820using Shuttle . Esb ;
1921using Shuttle . Esb . AzureStorageQueues ;
2022using Shuttle . Esb . Sql . Subscription ;
2123using Shuttle . Recall ;
24+ using Shuttle . Recall . Logging ;
25+ using Shuttle . Recall . Sql . EventProcessing ;
2226using Shuttle . Recall . Sql . Storage ;
2327
2428namespace Shuttle . Access . Server ;
@@ -56,6 +60,7 @@ private static async Task Main(string[] args)
5660
5761 services
5862 . AddSingleton < IConfiguration > ( configuration )
63+ . AddSingleton ( configuration . GetSection ( ServerOptions . SectionName ) . Get < ServerOptions > ( ) ?? new ServerOptions ( ) )
5964 . AddLogging ( builder =>
6065 {
6166 builder . AddSerilog ( ) ;
@@ -83,7 +88,25 @@ private static async Task Main(string[] args)
8388
8489 builder . UseSqlServer ( ) ;
8590 } )
86- . AddEventStore ( )
91+ . AddSqlEventProcessing ( builder =>
92+ {
93+ builder . Options . ConnectionStringName = "Access" ;
94+
95+ builder . UseSqlServer ( ) ;
96+ } )
97+ . AddEventStore ( builder =>
98+ {
99+ configuration . GetSection ( EventStoreOptions . SectionName ) . Bind ( builder . Options ) ;
100+
101+ builder . AddProjection ( ProjectionNames . Identity ) . AddEventHandler < IdentityHandler > ( ) ;
102+ builder . AddProjection ( ProjectionNames . Permission ) . AddEventHandler < PermissionHandler > ( ) ;
103+ builder . AddProjection ( ProjectionNames . Role ) . AddEventHandler < RoleHandler > ( ) ;
104+ } )
105+ . AddEventStoreLogging ( builder =>
106+ {
107+ builder . Options . AddPipelineEventType < OnPipelineException > ( ) ;
108+ builder . Options . AddPipelineEventType < OnAfterAcknowledgeEvent > ( ) ;
109+ } )
87110 . AddSqlSubscription ( builder =>
88111 {
89112 builder . Options . ConnectionStringName = "Access" ;
@@ -97,32 +120,9 @@ private static async Task Main(string[] args)
97120 } )
98121 . AddSingleton < IPasswordGenerator , DefaultPasswordGenerator > ( )
99122 . AddSingleton < IHashingService , HashingService > ( )
100- . AddSingleton < IHostedService , ApplicationHostedService > ( )
123+ . AddSingleton < IHostedService , ServerHostedService > ( )
124+ . AddSingleton < KeepAliveObserver > ( )
101125 . AddSingleton ( TracerProvider . Default . GetTracer ( "Shuttle.Access.Server" ) ) ;
102-
103- //services.AddOpenTelemetry()
104- // .WithTracing(
105- // builder => builder
106- // .AddServiceBusInstrumentation(openTelemetryBuilder =>
107- // {
108- // configuration.GetSection(ServiceBusOpenTelemetryOptions.SectionName).Bind(openTelemetryBuilder.Options);
109- // })
110- // .AddMediatorInstrumentation(openTelemetryBuilder =>
111- // {
112- // configuration.GetSection(MediatorOpenTelemetryOptions.SectionName).Bind(openTelemetryBuilder.Options);
113- // })
114- // .AddRecallInstrumentation(openTelemetryBuilder =>
115- // {
116- // configuration.GetSection(RecallOpenTelemetryOptions.SectionName).Bind(openTelemetryBuilder.Options);
117- // })
118- // .AddSqlClientInstrumentation(options =>
119- // {
120- // options.SetDbStatementForText = true;
121- // })
122- // .AddJaegerExporter(options =>
123- // {
124- // options.AgentHost = Environment.GetEnvironmentVariable("JAEGER_AGENT_HOST");
125- // }));
126126 } )
127127 . Build ( ) ;
128128
0 commit comments