@@ -63,7 +63,9 @@ public static IEndpointConventionBuilder Subscribe<TEvent>(
63
63
string appName )
64
64
where TEvent : IntegrationEvent
65
65
{
66
- var result = builder . EnsureProvision ( )
66
+ builder . EnsureDaprEventBus ( ) ;
67
+
68
+ var result = builder
67
69
. MapPost ( route , ( TEvent receivedEvent , IEventBus eventBus ) => eventBus . ReceiveAsync ( receivedEvent ) )
68
70
. WithTopic ( DaprOptions . PubSubName , DaprUtils . GetDaprTopicName < TEvent > ( appName ) ) ;
69
71
return result ;
@@ -76,7 +78,7 @@ public static IEndpointConventionBuilder Subscribe<TEvent>(
76
78
/// <param name="assemblies"><see cref="Assembly"/></param>
77
79
public static void Subscribe ( this IEndpointRouteBuilder builder , params Assembly [ ] assemblies )
78
80
{
79
- builder . EnsureProvision ( ) ;
81
+ builder . EnsureDaprEventBus ( ) ;
80
82
81
83
var method = typeof ( EndPointExtensions ) . GetMethod (
82
84
nameof ( Subscribe ) ,
@@ -98,11 +100,11 @@ public static void Subscribe(this IEndpointRouteBuilder builder, params Assembly
98
100
}
99
101
}
100
102
101
- private static DaprOptions EnsureEventBusRegistered ( this DaprOptions daprOptions , IEndpointRouteBuilder builder )
103
+ private static void EnsureEventBusRegistered ( this IEndpointRouteBuilder builder , DaprOptions daprOptions )
102
104
{
103
105
if ( daprOptions . IsEventBusRegistered )
104
106
{
105
- return daprOptions ;
107
+ return ;
106
108
}
107
109
108
110
var serviceCheck = builder . ServiceProvider . GetRequiredService < IServiceProviderIsService > ( ) ;
@@ -113,14 +115,14 @@ private static DaprOptions EnsureEventBusRegistered(this DaprOptions daprOptions
113
115
}
114
116
115
117
daprOptions . IsEventBusRegistered = true ;
116
- return daprOptions ;
118
+ return ;
117
119
}
118
120
119
- private static DaprOptions EnsureDaprSubscribeHandlerMapped ( this DaprOptions daprOptions , IEndpointRouteBuilder builder )
121
+ private static void EnsureDaprSubscribeHandlerMapped ( this IEndpointRouteBuilder builder , DaprOptions daprOptions )
120
122
{
121
123
if ( daprOptions . IsDaprSubscribeHandlerMapped )
122
124
{
123
- return daprOptions ;
125
+ return ;
124
126
}
125
127
126
128
if ( builder is IApplicationBuilder app )
@@ -130,17 +132,16 @@ private static DaprOptions EnsureDaprSubscribeHandlerMapped(this DaprOptions dap
130
132
131
133
builder . MapSubscribeHandler ( ) ;
132
134
daprOptions . IsDaprSubscribeHandlerMapped = true ;
133
- return daprOptions ;
135
+ return ;
134
136
}
135
137
136
138
private static DaprOptions GetDaprOptions ( this IEndpointRouteBuilder builder )
137
139
=> builder . ServiceProvider . GetRequiredService < IOptions < DaprOptions > > ( ) . Value ;
138
140
139
- private static IEndpointRouteBuilder EnsureProvision ( this IEndpointRouteBuilder builder )
141
+ private static void EnsureDaprEventBus ( this IEndpointRouteBuilder builder )
140
142
{
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 ) ;
145
146
}
146
147
}
0 commit comments