@@ -63,7 +63,9 @@ public static IEndpointConventionBuilder Subscribe<TEvent>(
6363 string appName )
6464 where TEvent : IntegrationEvent
6565 {
66- var result = builder . EnsureProvision ( )
66+ builder . EnsureDaprEventBus ( ) ;
67+
68+ var result = builder
6769 . MapPost ( route , ( TEvent receivedEvent , IEventBus eventBus ) => eventBus . ReceiveAsync ( receivedEvent ) )
6870 . WithTopic ( DaprOptions . PubSubName , DaprUtils . GetDaprTopicName < TEvent > ( appName ) ) ;
6971 return result ;
@@ -76,7 +78,7 @@ public static IEndpointConventionBuilder Subscribe<TEvent>(
7678 /// <param name="assemblies"><see cref="Assembly"/></param>
7779 public static void Subscribe ( this IEndpointRouteBuilder builder , params Assembly [ ] assemblies )
7880 {
79- builder . EnsureProvision ( ) ;
81+ builder . EnsureDaprEventBus ( ) ;
8082
8183 var method = typeof ( EndPointExtensions ) . GetMethod (
8284 nameof ( Subscribe ) ,
@@ -98,11 +100,11 @@ public static void Subscribe(this IEndpointRouteBuilder builder, params Assembly
98100 }
99101 }
100102
101- private static DaprOptions EnsureEventBusRegistered ( this DaprOptions daprOptions , IEndpointRouteBuilder builder )
103+ private static void EnsureEventBusRegistered ( this IEndpointRouteBuilder builder , DaprOptions daprOptions )
102104 {
103105 if ( daprOptions . IsEventBusRegistered )
104106 {
105- return daprOptions ;
107+ return ;
106108 }
107109
108110 var serviceCheck = builder . ServiceProvider . GetRequiredService < IServiceProviderIsService > ( ) ;
@@ -113,14 +115,14 @@ private static DaprOptions EnsureEventBusRegistered(this DaprOptions daprOptions
113115 }
114116
115117 daprOptions . IsEventBusRegistered = true ;
116- return daprOptions ;
118+ return ;
117119 }
118120
119- private static DaprOptions EnsureDaprSubscribeHandlerMapped ( this DaprOptions daprOptions , IEndpointRouteBuilder builder )
121+ private static void EnsureDaprSubscribeHandlerMapped ( this IEndpointRouteBuilder builder , DaprOptions daprOptions )
120122 {
121123 if ( daprOptions . IsDaprSubscribeHandlerMapped )
122124 {
123- return daprOptions ;
125+ return ;
124126 }
125127
126128 if ( builder is IApplicationBuilder app )
@@ -130,17 +132,16 @@ private static DaprOptions EnsureDaprSubscribeHandlerMapped(this DaprOptions dap
130132
131133 builder . MapSubscribeHandler ( ) ;
132134 daprOptions . IsDaprSubscribeHandlerMapped = true ;
133- return daprOptions ;
135+ return ;
134136 }
135137
136138 private static DaprOptions GetDaprOptions ( this IEndpointRouteBuilder builder )
137139 => builder . ServiceProvider . GetRequiredService < IOptions < DaprOptions > > ( ) . Value ;
138140
139- private static IEndpointRouteBuilder EnsureProvision ( this IEndpointRouteBuilder builder )
141+ private static void EnsureDaprEventBus ( this IEndpointRouteBuilder builder )
140142 {
141- builder . GetDaprOptions ( )
142- . EnsureDaprSubscribeHandlerMapped ( builder )
143- . EnsureEventBusRegistered ( builder ) ;
144- return builder ;
143+ var options = builder . GetDaprOptions ( ) ;
144+ builder . EnsureDaprSubscribeHandlerMapped ( options ) ;
145+ builder . EnsureEventBusRegistered ( options ) ;
145146 }
146147}
0 commit comments