File tree Expand file tree Collapse file tree 4 files changed +46
-10
lines changed
Expand file tree Collapse file tree 4 files changed +46
-10
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,42 @@ false
135135
136136## Network options
137137
138+ ### Retries
139+
140+ The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
141+
142+ Only the following error types are retried:
143+
144+ - Connection errors (for example, due to a network connectivity problem)
145+ - 408 Request Timeout
146+ - 409 Conflict
147+ - 429 Rate Limit
148+ - 5xx Internal
149+
150+ The API may also explicitly instruct the SDK to retry or not retry a request.
151+
152+ To set a custom number of retries, configure the client using the ` MaxRetries ` method:
153+
154+ ``` csharp
155+ using Orb ;
156+
157+ OrbClient client = new () { MaxRetries = 3 };
158+ ```
159+
160+ Or configure a single method call using [ ` WithOptions ` ] ( #modifying-configuration ) :
161+
162+ ``` csharp
163+ using System ;
164+
165+ var customer = await client
166+ .WithOptions (options =>
167+ options with { MaxRetries = 3 }
168+ )
169+ .Customers .Create (parameters );
170+
171+ Console .WriteLine (customer );
172+ ```
173+
138174### Timeouts
139175
140176Requests time out after 1 minute by default.
Original file line number Diff line number Diff 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 Lazy < string > _apiKey = new ( ( ) =>
2727 Environment . GetEnvironmentVariable ( "ORB_API_KEY" )
2828 ?? throw new OrbInvalidDataException (
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ public interface IOrbClient
3030
3131 bool ResponseValidation { get ; init ; }
3232
33- TimeSpan Timeout { get ; init ; }
34-
3533 int MaxRetries { get ; init ; }
3634
35+ TimeSpan Timeout { get ; init ; }
36+
3737 string APIKey { get ; init ; }
3838
3939 string ? WebhookSecret { get ; init ; }
Original file line number Diff line number Diff line change @@ -56,18 +56,18 @@ public bool ResponseValidation
5656 init { this . _options . ResponseValidation = value ; }
5757 }
5858
59- public TimeSpan Timeout
60- {
61- get { return this . _options . Timeout ; }
62- init { this . _options . Timeout = value ; }
63- }
64-
6559 public int MaxRetries
6660 {
6761 get { return this . _options . MaxRetries ; }
6862 init { this . _options . MaxRetries = value ; }
6963 }
7064
65+ public TimeSpan Timeout
66+ {
67+ get { return this . _options . Timeout ; }
68+ init { this . _options . Timeout = value ; }
69+ }
70+
7171 public string APIKey
7272 {
7373 get { return this . _options . APIKey ; }
You can’t perform that action at this time.
0 commit comments