Skip to content

Commit aecc000

Browse files
docs(client): document max retries
1 parent ce12fd4 commit aecc000

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,42 @@ false
131131

132132
## Network options
133133

134+
### Retries
135+
136+
The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
137+
138+
Only the following error types are retried:
139+
140+
- Connection errors (for example, due to a network connectivity problem)
141+
- 408 Request Timeout
142+
- 409 Conflict
143+
- 429 Rate Limit
144+
- 5xx Internal
145+
146+
The API may also explicitly instruct the SDK to retry or not retry a request.
147+
148+
To set a custom number of retries, configure the client using the `MaxRetries` method:
149+
150+
```csharp
151+
using ArcadeDotnet;
152+
153+
ArcadeClient client = new() { MaxRetries = 3 };
154+
```
155+
156+
Or configure a single method call using [`WithOptions`](#modifying-configuration):
157+
158+
```csharp
159+
using System;
160+
161+
var chatResponse = await client
162+
.WithOptions(options =>
163+
options with { MaxRetries = 3 }
164+
)
165+
.Chat.Completions.Create();
166+
167+
Console.WriteLine(chatResponse);
168+
```
169+
134170
### Timeouts
135171

136172
Requests time out after 1 minute by default.

src/ArcadeDotnet/ArcadeClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ public bool ResponseValidation
4646
init { this._options.ResponseValidation = value; }
4747
}
4848

49-
public TimeSpan Timeout
50-
{
51-
get { return this._options.Timeout; }
52-
init { this._options.Timeout = value; }
53-
}
54-
5549
public int MaxRetries
5650
{
5751
get { return this._options.MaxRetries; }
5852
init { this._options.MaxRetries = value; }
5953
}
6054

55+
public TimeSpan Timeout
56+
{
57+
get { return this._options.Timeout; }
58+
init { this._options.Timeout = value; }
59+
}
60+
6161
public string APIKey
6262
{
6363
get { return this._options.APIKey; }

src/ArcadeDotnet/Core/ClientOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public Uri BaseUrl
1919

2020
public bool ResponseValidation { get; set; } = false;
2121

22-
public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(1);
23-
2422
public int MaxRetries { get; set; } = 2;
2523

24+
public TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(1);
25+
2626
/// <summary>
2727
/// API key used for authorization in header
2828
/// </summary>

src/ArcadeDotnet/IArcadeClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public interface IArcadeClient
2020

2121
bool ResponseValidation { get; init; }
2222

23-
TimeSpan Timeout { get; init; }
24-
2523
int MaxRetries { get; init; }
2624

25+
TimeSpan Timeout { get; init; }
26+
2727
/// <summary>
2828
/// API key used for authorization in header
2929
/// </summary>

0 commit comments

Comments
 (0)