Skip to content

Commit eaff753

Browse files
committed
refactor
1 parent d095443 commit eaff753

File tree

3 files changed

+100
-90
lines changed

3 files changed

+100
-90
lines changed

src/Extensions/AzureBlobPayloads/Interceptors/AzureBlobPayloadsManagedBackendInterceptor.cs

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class AzureBlobPayloadsManagedBackendInterceptor(IPayloadStore pay
1313
: BasePayloadInterceptor<object, object>(payloadStore, options)
1414
{
1515
/// <inheritdoc/>
16-
protected override Task ExternalizeRequestPayloadsAsync<TRequest>(TRequest request, CancellationToken cancellation)
16+
protected override async Task ExternalizeRequestPayloadsAsync<TRequest>(TRequest request, CancellationToken cancellation)
1717
{
1818
// Azure Managed Backend -> Backend Service
1919
// Note: This interceptor is designed for backend_service.proto types, but since those types
@@ -22,88 +22,97 @@ protected override Task ExternalizeRequestPayloadsAsync<TRequest>(TRequest reque
2222
switch (request)
2323
{
2424
case P.CreateInstanceRequest r:
25-
return this.MaybeExternalizeAsync(v => r.Input = v, r.Input, cancellation);
25+
r.Input = await this.MaybeExternalizeAsync(r.Input, cancellation);
26+
break;
2627
case P.RaiseEventRequest r:
27-
return this.MaybeExternalizeAsync(v => r.Input = v, r.Input, cancellation);
28+
r.Input = await this.MaybeExternalizeAsync(r.Input, cancellation);
29+
break;
2830
case P.TerminateRequest r:
29-
return this.MaybeExternalizeAsync(v => r.Output = v, r.Output, cancellation);
31+
r.Output = await this.MaybeExternalizeAsync(r.Output, cancellation);
32+
break;
3033
case P.SuspendRequest r:
31-
return this.MaybeExternalizeAsync(v => r.Reason = v, r.Reason, cancellation);
34+
r.Reason = await this.MaybeExternalizeAsync(r.Reason, cancellation);
35+
break;
3236
case P.ResumeRequest r:
33-
return this.MaybeExternalizeAsync(v => r.Reason = v, r.Reason, cancellation);
37+
r.Reason = await this.MaybeExternalizeAsync(r.Reason, cancellation);
38+
break;
3439
case P.SignalEntityRequest r:
35-
return this.MaybeExternalizeAsync(v => r.Input = v, r.Input, cancellation);
40+
r.Input = await this.MaybeExternalizeAsync(r.Input, cancellation);
41+
break;
3642
case P.ActivityResponse r:
37-
return this.MaybeExternalizeAsync(v => r.Result = v, r.Result, cancellation);
43+
r.Result = await this.MaybeExternalizeAsync(r.Result, cancellation);
44+
break;
3845
case P.OrchestratorResponse r:
39-
return this.ExternalizeOrchestratorResponseAsync(r, cancellation);
46+
await this.ExternalizeOrchestratorResponseAsync(r, cancellation);
47+
break;
4048
case P.EntityBatchResult r:
41-
return this.ExternalizeEntityBatchResultAsync(r, cancellation);
49+
await this.ExternalizeEntityBatchResultAsync(r, cancellation);
50+
break;
4251
case P.EntityBatchRequest r:
43-
return this.ExternalizeEntityBatchRequestAsync(r, cancellation);
52+
await this.ExternalizeEntityBatchRequestAsync(r, cancellation);
53+
break;
4454
case P.EntityRequest r:
45-
return this.MaybeExternalizeAsync(v => r.EntityState = v, r.EntityState, cancellation);
55+
r.EntityState = await this.MaybeExternalizeAsync(r.EntityState, cancellation);
56+
break;
4657
}
47-
48-
return Task.CompletedTask;
4958
}
5059

5160
async Task ExternalizeOrchestratorResponseAsync(P.OrchestratorResponse r, CancellationToken cancellation)
5261
{
53-
await this.MaybeExternalizeAsync(v => r.CustomStatus = v, r.CustomStatus, cancellation);
62+
r.CustomStatus = await this.MaybeExternalizeAsync(r.CustomStatus, cancellation);
5463
foreach (P.OrchestratorAction a in r.Actions)
5564
{
5665
if (a.CompleteOrchestration is { } complete)
5766
{
58-
await this.MaybeExternalizeAsync(v => complete.Result = v, complete.Result, cancellation);
59-
await this.MaybeExternalizeAsync(v => complete.Details = v, complete.Details, cancellation);
67+
complete.Result = await this.MaybeExternalizeAsync(complete.Result, cancellation);
68+
complete.Details = await this.MaybeExternalizeAsync(complete.Details, cancellation);
6069
}
6170

6271
if (a.TerminateOrchestration is { } term)
6372
{
64-
await this.MaybeExternalizeAsync(v => term.Reason = v, term.Reason, cancellation);
73+
term.Reason = await this.MaybeExternalizeAsync(term.Reason, cancellation);
6574
}
6675

6776
if (a.ScheduleTask is { } schedule)
6877
{
69-
await this.MaybeExternalizeAsync(v => schedule.Input = v, schedule.Input, cancellation);
78+
schedule.Input = await this.MaybeExternalizeAsync(schedule.Input, cancellation);
7079
}
7180

7281
if (a.CreateSubOrchestration is { } sub)
7382
{
74-
await this.MaybeExternalizeAsync(v => sub.Input = v, sub.Input, cancellation);
83+
sub.Input = await this.MaybeExternalizeAsync(sub.Input, cancellation);
7584
}
7685

7786
if (a.SendEvent is { } sendEvt)
7887
{
79-
await this.MaybeExternalizeAsync(v => sendEvt.Data = v, sendEvt.Data, cancellation);
88+
sendEvt.Data = await this.MaybeExternalizeAsync(sendEvt.Data, cancellation);
8089
}
8190

8291
if (a.SendEntityMessage is { } entityMsg)
8392
{
8493
if (entityMsg.EntityOperationSignaled is { } sig)
8594
{
86-
await this.MaybeExternalizeAsync(v => sig.Input = v, sig.Input, cancellation);
95+
sig.Input = await this.MaybeExternalizeAsync(sig.Input, cancellation);
8796
}
8897

8998
if (entityMsg.EntityOperationCalled is { } called)
9099
{
91-
await this.MaybeExternalizeAsync(v => called.Input = v, called.Input, cancellation);
100+
called.Input = await this.MaybeExternalizeAsync(called.Input, cancellation);
92101
}
93102
}
94103
}
95104
}
96105

97106
async Task ExternalizeEntityBatchResultAsync(P.EntityBatchResult r, CancellationToken cancellation)
98107
{
99-
await this.MaybeExternalizeAsync(v => r.EntityState = v, r.EntityState, cancellation);
108+
r.EntityState = await this.MaybeExternalizeAsync(r.EntityState, cancellation);
100109
if (r.Results != null)
101110
{
102111
foreach (P.OperationResult result in r.Results)
103112
{
104113
if (result.Success is { } success)
105114
{
106-
await this.MaybeExternalizeAsync(v => success.Result = v, success.Result, cancellation);
115+
success.Result = await this.MaybeExternalizeAsync(success.Result, cancellation);
107116
}
108117
}
109118
}
@@ -114,25 +123,25 @@ async Task ExternalizeEntityBatchResultAsync(P.EntityBatchResult r, Cancellation
114123
{
115124
if (action.SendSignal is { } sendSig)
116125
{
117-
await this.MaybeExternalizeAsync(v => sendSig.Input = v, sendSig.Input, cancellation);
126+
sendSig.Input = await this.MaybeExternalizeAsync(sendSig.Input, cancellation);
118127
}
119128

120129
if (action.StartNewOrchestration is { } start)
121130
{
122-
await this.MaybeExternalizeAsync(v => start.Input = v, start.Input, cancellation);
131+
start.Input = await this.MaybeExternalizeAsync(start.Input, cancellation);
123132
}
124133
}
125134
}
126135
}
127136

128137
async Task ExternalizeEntityBatchRequestAsync(P.EntityBatchRequest r, CancellationToken cancellation)
129138
{
130-
await this.MaybeExternalizeAsync(v => r.EntityState = v, r.EntityState, cancellation);
139+
r.EntityState = await this.MaybeExternalizeAsync(r.EntityState, cancellation);
131140
if (r.Operations != null)
132141
{
133142
foreach (P.OperationRequest op in r.Operations)
134143
{
135-
await this.MaybeExternalizeAsync(v => op.Input = v, op.Input, cancellation);
144+
op.Input = await this.MaybeExternalizeAsync(op.Input, cancellation);
136145
}
137146
}
138147
}
@@ -144,121 +153,121 @@ async Task ExternalizeHistoryEventAsync(P.HistoryEvent e, CancellationToken canc
144153
case P.HistoryEvent.EventTypeOneofCase.ExecutionStarted:
145154
if (e.ExecutionStarted is { } es)
146155
{
147-
await this.MaybeExternalizeAsync(v => es.Input = v, es.Input, cancellation);
156+
es.Input = await this.MaybeExternalizeAsync(es.Input, cancellation);
148157
}
149158

150159
break;
151160
case P.HistoryEvent.EventTypeOneofCase.ExecutionCompleted:
152161
if (e.ExecutionCompleted is { } ec)
153162
{
154-
await this.MaybeExternalizeAsync(v => ec.Result = v, ec.Result, cancellation);
163+
ec.Result = await this.MaybeExternalizeAsync(ec.Result, cancellation);
155164
}
156165

157166
break;
158167
case P.HistoryEvent.EventTypeOneofCase.EventRaised:
159168
if (e.EventRaised is { } er)
160169
{
161-
await this.MaybeExternalizeAsync(v => er.Input = v, er.Input, cancellation);
170+
er.Input = await this.MaybeExternalizeAsync(er.Input, cancellation);
162171
}
163172

164173
break;
165174
case P.HistoryEvent.EventTypeOneofCase.TaskScheduled:
166175
if (e.TaskScheduled is { } ts)
167176
{
168-
await this.MaybeExternalizeAsync(v => ts.Input = v, ts.Input, cancellation);
177+
ts.Input = await this.MaybeExternalizeAsync(ts.Input, cancellation);
169178
}
170179

171180
break;
172181
case P.HistoryEvent.EventTypeOneofCase.TaskCompleted:
173182
if (e.TaskCompleted is { } tc)
174183
{
175-
await this.MaybeExternalizeAsync(v => tc.Result = v, tc.Result, cancellation);
184+
tc.Result = await this.MaybeExternalizeAsync(tc.Result, cancellation);
176185
}
177186

178187
break;
179188
case P.HistoryEvent.EventTypeOneofCase.SubOrchestrationInstanceCreated:
180189
if (e.SubOrchestrationInstanceCreated is { } soc)
181190
{
182-
await this.MaybeExternalizeAsync(v => soc.Input = v, soc.Input, cancellation);
191+
soc.Input = await this.MaybeExternalizeAsync(soc.Input, cancellation);
183192
}
184193

185194
break;
186195
case P.HistoryEvent.EventTypeOneofCase.SubOrchestrationInstanceCompleted:
187196
if (e.SubOrchestrationInstanceCompleted is { } sox)
188197
{
189-
await this.MaybeExternalizeAsync(v => sox.Result = v, sox.Result, cancellation);
198+
sox.Result = await this.MaybeExternalizeAsync(sox.Result, cancellation);
190199
}
191200

192201
break;
193202
case P.HistoryEvent.EventTypeOneofCase.EventSent:
194203
if (e.EventSent is { } esent)
195204
{
196-
await this.MaybeExternalizeAsync(v => esent.Input = v, esent.Input, cancellation);
205+
esent.Input = await this.MaybeExternalizeAsync(esent.Input, cancellation);
197206
}
198207

199208
break;
200209
case P.HistoryEvent.EventTypeOneofCase.GenericEvent:
201210
if (e.GenericEvent is { } ge)
202211
{
203-
await this.MaybeExternalizeAsync(v => ge.Data = v, ge.Data, cancellation);
212+
ge.Data = await this.MaybeExternalizeAsync(ge.Data, cancellation);
204213
}
205214

206215
break;
207216
case P.HistoryEvent.EventTypeOneofCase.ContinueAsNew:
208217
if (e.ContinueAsNew is { } can)
209218
{
210-
await this.MaybeExternalizeAsync(v => can.Input = v, can.Input, cancellation);
219+
can.Input = await this.MaybeExternalizeAsync(can.Input, cancellation);
211220
}
212221

213222
break;
214223
case P.HistoryEvent.EventTypeOneofCase.ExecutionTerminated:
215224
if (e.ExecutionTerminated is { } et)
216225
{
217-
await this.MaybeExternalizeAsync(v => et.Input = v, et.Input, cancellation);
226+
et.Input = await this.MaybeExternalizeAsync(et.Input, cancellation);
218227
}
219228

220229
break;
221230
case P.HistoryEvent.EventTypeOneofCase.ExecutionSuspended:
222231
if (e.ExecutionSuspended is { } esus)
223232
{
224-
await this.MaybeExternalizeAsync(v => esus.Input = v, esus.Input, cancellation);
233+
esus.Input = await this.MaybeExternalizeAsync(esus.Input, cancellation);
225234
}
226235

227236
break;
228237
case P.HistoryEvent.EventTypeOneofCase.ExecutionResumed:
229238
if (e.ExecutionResumed is { } eres)
230239
{
231-
await this.MaybeExternalizeAsync(v => eres.Input = v, eres.Input, cancellation);
240+
eres.Input = await this.MaybeExternalizeAsync(eres.Input, cancellation);
232241
}
233242

234243
break;
235244
case P.HistoryEvent.EventTypeOneofCase.EntityOperationSignaled:
236245
if (e.EntityOperationSignaled is { } eos)
237246
{
238-
await this.MaybeExternalizeAsync(v => eos.Input = v, eos.Input, cancellation);
247+
eos.Input = await this.MaybeExternalizeAsync(eos.Input, cancellation);
239248
}
240249

241250
break;
242251
case P.HistoryEvent.EventTypeOneofCase.EntityOperationCalled:
243252
if (e.EntityOperationCalled is { } eoc)
244253
{
245-
await this.MaybeExternalizeAsync(v => eoc.Input = v, eoc.Input, cancellation);
254+
eoc.Input = await this.MaybeExternalizeAsync(eoc.Input, cancellation);
246255
}
247256

248257
break;
249258
case P.HistoryEvent.EventTypeOneofCase.EntityOperationCompleted:
250259
if (e.EntityOperationCompleted is { } ecomp)
251260
{
252-
await this.MaybeExternalizeAsync(v => ecomp.Output = v, ecomp.Output, cancellation);
261+
ecomp.Output = await this.MaybeExternalizeAsync(ecomp.Output, cancellation);
253262
}
254263

255264
break;
256265
case P.HistoryEvent.EventTypeOneofCase.HistoryState:
257266
if (e.HistoryState is { } hs && hs.OrchestrationState is { } os)
258267
{
259-
await this.MaybeExternalizeAsync(v => os.Input = v, os.Input, cancellation);
260-
await this.MaybeExternalizeAsync(v => os.Output = v, os.Output, cancellation);
261-
await this.MaybeExternalizeAsync(v => os.CustomStatus = v, os.CustomStatus, cancellation);
268+
os.Input = await this.MaybeExternalizeAsync(os.Input, cancellation);
269+
os.Output = await this.MaybeExternalizeAsync(os.Output, cancellation);
270+
os.CustomStatus = await this.MaybeExternalizeAsync(os.CustomStatus, cancellation);
262271
}
263272

264273
break;

0 commit comments

Comments
 (0)