@@ -20,7 +20,7 @@ public sealed class GrpcDurableTaskClient : DurableTaskClient
20
20
readonly ILogger logger ;
21
21
readonly TaskHubSidecarServiceClient sidecarClient ;
22
22
readonly GrpcDurableTaskClientOptions options ;
23
- readonly AsyncDisposable asyncDisposable ;
23
+ AsyncDisposable asyncDisposable ;
24
24
25
25
/// <summary>
26
26
/// Initializes a new instance of the <see cref="GrpcDurableTaskClient"/> class.
@@ -46,7 +46,7 @@ public GrpcDurableTaskClient(string name, GrpcDurableTaskClientOptions options,
46
46
{
47
47
this . logger = Check . NotNull ( logger ) ;
48
48
this . options = Check . NotNull ( options ) ;
49
- this . asyncDisposable = this . BuildChannel ( out Channel channel ) ;
49
+ this . asyncDisposable = BuildChannel ( options , out GrpcChannel channel ) ;
50
50
this . sidecarClient = new TaskHubSidecarServiceClient ( channel ) ;
51
51
}
52
52
@@ -336,6 +336,43 @@ public override Task<PurgeResult> PurgeInstancesAsync(
336
336
return this . PurgeInstancesCoreAsync ( request , cancellation ) ;
337
337
}
338
338
339
+ static AsyncDisposable BuildChannel ( GrpcDurableTaskClientOptions options , out GrpcChannel channel )
340
+ {
341
+ if ( options . Channel is GrpcChannel c )
342
+ {
343
+ channel = c ;
344
+ return default ;
345
+ }
346
+
347
+ c = GetChannel ( options . Address ) ;
348
+ channel = c ;
349
+ return new AsyncDisposable ( async ( ) => await c . ShutdownAsync ( ) ) ;
350
+ }
351
+
352
+ #if NET6_0_OR_GREATER
353
+ static GrpcChannel GetChannel ( string ? address )
354
+ {
355
+ if ( string . IsNullOrEmpty ( address ) )
356
+ {
357
+ address = "http://localhost:4001" ;
358
+ }
359
+
360
+ return GrpcChannel . ForAddress ( address ) ;
361
+ }
362
+ #endif
363
+
364
+ #if NETSTANDARD2_0
365
+ static GrpcChannel GetChannel ( string ? address )
366
+ {
367
+ if ( string . IsNullOrEmpty ( address ) )
368
+ {
369
+ address = "localhost:4001" ;
370
+ }
371
+
372
+ return new ( address , ChannelCredentials . Insecure ) ;
373
+ }
374
+ #endif
375
+
339
376
async Task < PurgeResult > PurgeInstancesCoreAsync (
340
377
P . PurgeInstancesRequest request , CancellationToken cancellation = default )
341
378
{
@@ -362,24 +399,8 @@ OrchestrationMetadata CreateMetadata(P.OrchestrationState state, bool includeInp
362
399
SerializedInput = state . Input ,
363
400
SerializedOutput = state . Output ,
364
401
SerializedCustomStatus = state . CustomStatus ,
365
- FailureDetails = ProtoUtils . ConvertTaskFailureDetails ( state . FailureDetails ) ,
402
+ FailureDetails = state . FailureDetails . ToTaskFailureDetails ( ) ,
366
403
DataConverter = includeInputsAndOutputs ? this . DataConverter : null ,
367
404
} ;
368
405
}
369
-
370
- AsyncDisposable BuildChannel ( out Channel channel )
371
- {
372
- if ( this . options . Channel is Channel c )
373
- {
374
- channel = c ;
375
- return default ;
376
- }
377
-
378
- string address = string . IsNullOrEmpty ( this . options . Address ) ? "localhost:4001" : this . options . Address ! ;
379
-
380
- // TODO: use SSL channel by default?
381
- c = new ( address , ChannelCredentials . Insecure ) ;
382
- channel = c ;
383
- return new AsyncDisposable ( async ( ) => await c . ShutdownAsync ( ) ) ;
384
- }
385
406
}
0 commit comments