-
Notifications
You must be signed in to change notification settings - Fork 502
Expand file tree
/
Copy pathRetryOptionsExtensions.cs
More file actions
46 lines (38 loc) · 1.23 KB
/
RetryOptionsExtensions.cs
File metadata and controls
46 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Text;
using Azure.Core;
using Microsoft.Mcp.Core.Options;
namespace Azure.Mcp.Core.Options;
public static class RetryOptionsExtensions
{
public static void ConfigureRetryOptions(this ClientOptions clientOptions, RetryPolicyOptions? retryPolicy)
{
if (retryPolicy == null)
{
return;
}
if (retryPolicy.MaxRetries.HasValue)
{
clientOptions.Retry.MaxRetries = retryPolicy.MaxRetries.Value;
}
if (retryPolicy.Mode.HasValue)
{
clientOptions.Retry.Mode = retryPolicy.Mode.Value;
}
if (retryPolicy.DelaySeconds.HasValue)
{
clientOptions.Retry.Delay = TimeSpan.FromSeconds(retryPolicy.DelaySeconds.Value);
}
if (retryPolicy.MaxDelaySeconds.HasValue)
{
clientOptions.Retry.MaxDelay = TimeSpan.FromSeconds(retryPolicy.MaxDelaySeconds.Value);
}
if (retryPolicy.NetworkTimeoutSeconds.HasValue)
{
clientOptions.Retry.NetworkTimeout = TimeSpan.FromSeconds(retryPolicy.NetworkTimeoutSeconds.Value);
}
}
}