-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement automatic rate-limit handling (#512)
* Implement automatic rate-limit handling * Move random instance to class level * Use ConcurrentRandom * Try fixing CI
- Loading branch information
1 parent
710ad58
commit e20b81b
Showing
36 changed files
with
317 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace Auth0.Core | ||
{ | ||
internal sealed class ConcurrentRandom | ||
{ | ||
private static readonly Random SRandom = new Random(); | ||
|
||
/// <summary> | ||
/// Returns a random integer that is within a specified range. | ||
/// </summary> | ||
/// <param name="minValue">The inclusive lower bound of the random number returned.</param> | ||
/// <param name="maxValue">The exclusive upper bound of the random number returned. <paramref name="maxValue" /> must be greater than or equal to <paramref name="minValue" />.</param> | ||
/// <returns>A 32-bit signed integer greater than or equal to <paramref name="minValue" /> and less than <paramref name="maxValue" />; that is, the range of return values includes <paramref name="minValue" /> but not <paramref name="maxValue" />. If <paramref name="minValue" /> equals <paramref name="maxValue" />, <paramref name="minValue" /> is returned.</returns> | ||
public int Next(int minValue, int maxValue) | ||
{ | ||
lock (SRandom) | ||
{ | ||
return SRandom.Next(minValue, maxValue); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Auth0.ManagementApi/HttpClientManagementConnectionOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Auth0.ManagementApi | ||
{ | ||
public class HttpClientManagementConnectionOptions | ||
{ | ||
/// <summary> | ||
/// Set the maximum number of consecutive retries for Management API requests that fail due to rate-limits being reached. | ||
/// By default, rate-limited requests will be retries a maximum of three times.To disable retries on rate-limit | ||
/// errors, set this value to zero. | ||
/// </summary> | ||
/// <remarks>Must be a number between zero (do not retry) and ten.</remarks> | ||
public int? NumberOfHttpRetries { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
tests/Auth0.AuthenticationApi.IntegrationTests/Testing/TestHttpClientManagementConnection.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.