Skip to content

Commit

Permalink
Add public Delay and RetryPolicy types (Azure#35391)
Browse files Browse the repository at this point in the history
* Add public Delay and RetryPolicy types

* change log

* Apply suggestions from code review

Co-authored-by: Christopher Scott <[email protected]>

* PR fb

* Add RetryAfter parameter

---------

Co-authored-by: Christopher Scott <[email protected]>
  • Loading branch information
JoshLove-msft and christothes authored Apr 6, 2023
1 parent cf3ed35 commit bdac330
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 139 deletions.
3 changes: 3 additions & 0 deletions sdk/core/Azure.Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added

- Added the `RetryPolicy` type which can be used to create a custom retry policy.
- Added the `Delay` type which can be used to customize delays.

### Breaking Changes

### Bugs Fixed
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.net461.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.
public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; }
public override string ToString() { throw null; }
}
public abstract partial class Delay
{
protected Delay(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { }
public static Azure.Core.Delay CreateExponentialDelay(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; }
public static Azure.Core.Delay CreateFixedDelay(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; }
public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; }
protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber);
protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
}
public static partial class DelegatedTokenCredential
{
public static Azure.Core.TokenCredential Create(System.Func<Azure.Core.TokenRequestContext, System.Threading.CancellationToken, Azure.Core.AccessToken> getToken) { throw null; }
Expand Down Expand Up @@ -1023,6 +1033,21 @@ public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemo
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { }
}
public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
public RetryPolicy(int maxRetries = 3, Azure.Core.Delay? delay = null) { }
protected Azure.Core.Delay Delay { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected virtual System.Threading.Tasks.ValueTask<System.TimeSpan> GetNextDelayAsync(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; }
protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; }
public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
protected internal virtual System.Threading.Tasks.ValueTask<bool> ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
}
public partial class ServerCertificateCustomValidationArgs
{
public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { }
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.
public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; }
public override string ToString() { throw null; }
}
public abstract partial class Delay
{
protected Delay(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { }
public static Azure.Core.Delay CreateExponentialDelay(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; }
public static Azure.Core.Delay CreateFixedDelay(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; }
public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; }
protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber);
protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
}
public static partial class DelegatedTokenCredential
{
public static Azure.Core.TokenCredential Create(System.Func<Azure.Core.TokenRequestContext, System.Threading.CancellationToken, Azure.Core.AccessToken> getToken) { throw null; }
Expand Down Expand Up @@ -1023,6 +1033,21 @@ public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemo
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { }
}
public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
public RetryPolicy(int maxRetries = 3, Azure.Core.Delay? delay = null) { }
protected Azure.Core.Delay Delay { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected virtual System.Threading.Tasks.ValueTask<System.TimeSpan> GetNextDelayAsync(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; }
protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; }
public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
protected internal virtual System.Threading.Tasks.ValueTask<bool> ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
}
public partial class ServerCertificateCustomValidationArgs
{
public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { }
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.
public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; }
public override string ToString() { throw null; }
}
public abstract partial class Delay
{
protected Delay(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { }
public static Azure.Core.Delay CreateExponentialDelay(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; }
public static Azure.Core.Delay CreateFixedDelay(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; }
public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; }
protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber);
protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
}
public static partial class DelegatedTokenCredential
{
public static Azure.Core.TokenCredential Create(System.Func<Azure.Core.TokenRequestContext, System.Threading.CancellationToken, Azure.Core.AccessToken> getToken) { throw null; }
Expand Down Expand Up @@ -1023,6 +1033,21 @@ public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemo
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { }
}
public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
public RetryPolicy(int maxRetries = 3, Azure.Core.Delay? delay = null) { }
protected Azure.Core.Delay Delay { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected virtual System.Threading.Tasks.ValueTask<System.TimeSpan> GetNextDelayAsync(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; }
protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; }
public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
protected internal virtual System.Threading.Tasks.ValueTask<bool> ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
}
public partial class ServerCertificateCustomValidationArgs
{
public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { }
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.
public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; }
public override string ToString() { throw null; }
}
public abstract partial class Delay
{
protected Delay(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { }
public static Azure.Core.Delay CreateExponentialDelay(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; }
public static Azure.Core.Delay CreateFixedDelay(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; }
public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; }
protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber);
protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
}
public static partial class DelegatedTokenCredential
{
public static Azure.Core.TokenCredential Create(System.Func<Azure.Core.TokenRequestContext, System.Threading.CancellationToken, Azure.Core.AccessToken> getToken) { throw null; }
Expand Down Expand Up @@ -1023,6 +1033,21 @@ public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemo
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { }
}
public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
public RetryPolicy(int maxRetries = 3, Azure.Core.Delay? delay = null) { }
protected Azure.Core.Delay Delay { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected virtual System.Threading.Tasks.ValueTask<System.TimeSpan> GetNextDelayAsync(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; }
protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; }
public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
protected internal virtual System.Threading.Tasks.ValueTask<bool> ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
}
public partial class ServerCertificateCustomValidationArgs
{
public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { }
Expand Down
25 changes: 25 additions & 0 deletions sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.
public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; }
public override string ToString() { throw null; }
}
public abstract partial class Delay
{
protected Delay(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { }
public static Azure.Core.Delay CreateExponentialDelay(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; }
public static Azure.Core.Delay CreateFixedDelay(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; }
public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; }
protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber);
protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; }
}
public static partial class DelegatedTokenCredential
{
public static Azure.Core.TokenCredential Create(System.Func<Azure.Core.TokenRequestContext, System.Threading.CancellationToken, Azure.Core.AccessToken> getToken) { throw null; }
Expand Down Expand Up @@ -1023,6 +1033,21 @@ public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemo
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { }
}
public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy
{
public RetryPolicy(int maxRetries = 3, Azure.Core.Delay? delay = null) { }
protected Azure.Core.Delay Delay { get { throw null; } }
protected virtual System.TimeSpan GetNextDelay(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected virtual System.Threading.Tasks.ValueTask<System.TimeSpan> GetNextDelayAsync(Azure.Core.HttpMessage message, System.TimeSpan? retryAfter) { throw null; }
protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; }
protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { }
protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; }
public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { }
public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory<Azure.Core.Pipeline.HttpPipelinePolicy> pipeline) { throw null; }
protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
protected internal virtual System.Threading.Tasks.ValueTask<bool> ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; }
}
public partial class ServerCertificateCustomValidationArgs
{
public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { }
Expand Down
Loading

0 comments on commit bdac330

Please sign in to comment.