| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | namespace IceRpc.Retry; |
| | 4 | |
|
| | 5 | | /// <summary>A property bag used to configure a <see cref="RetryInterceptor" />.</summary> |
| | 6 | | public sealed record class RetryOptions |
| | 7 | | { |
| | 8 | | /// <summary>Gets or sets the maximum number of attempts for retrying a request.</summary> |
| | 9 | | /// <value>The maximum number of attempts for retrying a request. Defaults to <c>2</c> attempts.</value> |
| | 10 | | public int MaxAttempts |
| | 11 | | { |
| 16 | 12 | | get => _maxAttempts; |
| | 13 | | set |
| 3 | 14 | | { |
| 3 | 15 | | if (value < 1) |
| 0 | 16 | | { |
| 0 | 17 | | throw new ArgumentOutOfRangeException( |
| 0 | 18 | | nameof(value), |
| 0 | 19 | | $"Invalid value '{value}' for '{nameof(MaxAttempts)}', it must be greater than 0."); |
| | 20 | | } |
| 3 | 21 | | _maxAttempts = value; |
| 3 | 22 | | } |
| | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary>Gets or sets the maximum size of the request payload in bytes for which retries would be considered. |
| | 26 | | /// Requests with a larger payload or a payload continuation are never retried.</summary> |
| | 27 | | /// <value>The maximum request payload size in bytes for which retries will be attempted. Defaults to <c>1</c> MB. |
| | 28 | | /// </value> |
| | 29 | | /// <remarks>The ability to retry depends on keeping the request payload around until a successful response has been |
| | 30 | | /// received or retries are no longer possible, this setting affects the working memory that the application will |
| | 31 | | /// consume.</remarks> |
| | 32 | | public int MaxPayloadSize |
| | 33 | | { |
| 16 | 34 | | get => _maxPayloadSize; |
| | 35 | | set |
| 0 | 36 | | { |
| 0 | 37 | | if (value < 1) |
| 0 | 38 | | { |
| 0 | 39 | | throw new ArgumentOutOfRangeException( |
| 0 | 40 | | nameof(value), |
| 0 | 41 | | $"Invalid value '{value}' for '{nameof(MaxPayloadSize)}' it must be greater than 0."); |
| | 42 | | } |
| 0 | 43 | | _maxPayloadSize = value; |
| 0 | 44 | | } |
| | 45 | | } |
| | 46 | |
|
| 16 | 47 | | private int _maxAttempts = 2; |
| 16 | 48 | | private int _maxPayloadSize = 1024 * 1024; |
| | 49 | | } |