Skip to content

Commit 74805f3

Browse files
committed
Dts Grpc client retry support
1 parent e32fa7a commit 74805f3

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/Client/AzureManaged/DurableTaskSchedulerClientOptions.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Azure.Identity;
77
using Grpc.Core;
88
using Grpc.Net.Client;
9+
using Grpc.Net.Client.Configuration;
910

1011
namespace Microsoft.DurableTask;
1112

@@ -112,6 +113,24 @@ this.Credential is not null
112113
{
113114
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds),
114115
UnsafeUseInsecureChannelCallCredentials = this.AllowInsecureCredentials,
116+
ServiceConfig = new ServiceConfig
117+
{
118+
MethodConfigs =
119+
{
120+
new MethodConfig
121+
{
122+
Names = { MethodName.Default },
123+
RetryPolicy = new Grpc.Net.Client.Configuration.RetryPolicy()
124+
{
125+
MaxAttempts = 10,
126+
InitialBackoff = TimeSpan.FromMilliseconds(50),
127+
MaxBackoff = TimeSpan.FromMilliseconds(250),
128+
BackoffMultiplier = 2,
129+
RetryableStatusCodes = { StatusCode.Unavailable },
130+
},
131+
},
132+
},
133+
},
115134
});
116135
}
117136

@@ -127,7 +146,7 @@ this.Credential is not null
127146
case "managedidentity":
128147
return new ManagedIdentityCredential(connectionString.ClientId);
129148
case "workloadidentity":
130-
var opts = new WorkloadIdentityCredentialOptions();
149+
WorkloadIdentityCredentialOptions opts = new WorkloadIdentityCredentialOptions();
131150
if (!string.IsNullOrEmpty(connectionString.ClientId))
132151
{
133152
opts.ClientId = connectionString.ClientId;

src/Worker/AzureManaged/DurableTaskSchedulerWorkerOptions.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Azure.Identity;
77
using Grpc.Core;
88
using Grpc.Net.Client;
9+
using Grpc.Net.Client.Configuration;
910

1011
namespace Microsoft.DurableTask;
1112

@@ -119,6 +120,24 @@ this.Credential is not null
119120
{
120121
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds),
121122
UnsafeUseInsecureChannelCallCredentials = this.AllowInsecureCredentials,
123+
ServiceConfig = new ServiceConfig
124+
{
125+
MethodConfigs =
126+
{
127+
new MethodConfig
128+
{
129+
Names = { MethodName.Default },
130+
RetryPolicy = new Grpc.Net.Client.Configuration.RetryPolicy()
131+
{
132+
MaxAttempts = 10,
133+
InitialBackoff = TimeSpan.FromMilliseconds(50),
134+
MaxBackoff = TimeSpan.FromMilliseconds(250),
135+
BackoffMultiplier = 2,
136+
RetryableStatusCodes = { StatusCode.Unavailable },
137+
},
138+
},
139+
},
140+
},
122141
});
123142
}
124143

@@ -134,7 +153,7 @@ this.Credential is not null
134153
case "managedidentity":
135154
return new ManagedIdentityCredential(connectionString.ClientId);
136155
case "workloadidentity":
137-
var opts = new WorkloadIdentityCredentialOptions();
156+
WorkloadIdentityCredentialOptions opts = new WorkloadIdentityCredentialOptions();
138157
if (!string.IsNullOrEmpty(connectionString.ClientId))
139158
{
140159
opts.ClientId = connectionString.ClientId;

0 commit comments

Comments
 (0)