Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Polly.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,17 @@ Polly.ResilienceStrategy.ExecuteAsync<TState>(System.Func<TState, System.Threadi
Polly.ResilienceStrategy.ExecuteOutcomeAsync<TResult, TState>(System.Func<Polly.ResilienceContext!, TState, System.Threading.Tasks.ValueTask<Polly.Outcome<TResult>>>! callback, Polly.ResilienceContext! context, TState state) -> System.Threading.Tasks.ValueTask<Polly.Outcome<TResult>>
Polly.ResilienceStrategy.ResilienceStrategy() -> void
Polly.ResilienceStrategy<TResult>
Polly.ResilienceStrategy<TResult>.Execute(System.Func<Polly.ResilienceContext!, TResult>! callback, Polly.ResilienceContext! context) -> TResult
Polly.ResilienceStrategy<TResult>.Execute(System.Func<System.Threading.CancellationToken, TResult>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> TResult
Polly.ResilienceStrategy<TResult>.Execute(System.Func<TResult>! callback) -> TResult
Polly.ResilienceStrategy<TResult>.Execute<TState>(System.Func<Polly.ResilienceContext!, TState, TResult>! callback, Polly.ResilienceContext! context, TState state) -> TResult
Polly.ResilienceStrategy<TResult>.Execute<TState>(System.Func<TState, System.Threading.CancellationToken, TResult>! callback, TState state, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> TResult
Polly.ResilienceStrategy<TResult>.Execute<TState>(System.Func<TState, TResult>! callback, TState state) -> TResult
Polly.ResilienceStrategy<TResult>.ExecuteAsync(System.Func<Polly.ResilienceContext!, System.Threading.Tasks.ValueTask<TResult>>! callback, Polly.ResilienceContext! context) -> System.Threading.Tasks.ValueTask<TResult>
Polly.ResilienceStrategy<TResult>.ExecuteAsync(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<TResult>>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
Polly.ResilienceStrategy<TResult>.ExecuteAsync<TState>(System.Func<Polly.ResilienceContext!, TState, System.Threading.Tasks.ValueTask<TResult>>! callback, Polly.ResilienceContext! context, TState state) -> System.Threading.Tasks.ValueTask<TResult>
Polly.ResilienceStrategy<TResult>.ExecuteAsync<TState>(System.Func<TState, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<TResult>>! callback, TState state, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<TResult>
Polly.ResilienceStrategy<TResult>.ExecuteOutcomeAsync<TState>(System.Func<Polly.ResilienceContext!, TState, System.Threading.Tasks.ValueTask<Polly.Outcome<TResult>>>! callback, Polly.ResilienceContext! context, TState state) -> System.Threading.Tasks.ValueTask<Polly.Outcome<TResult>>
Polly.ResilienceStrategy<TResult>.Execute<T, TState>(System.Func<Polly.ResilienceContext!, TState, T>! callback, Polly.ResilienceContext! context, TState state) -> T
Polly.ResilienceStrategy<TResult>.Execute<T, TState>(System.Func<TState, System.Threading.CancellationToken, T>! callback, TState state, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T
Polly.ResilienceStrategy<TResult>.Execute<T, TState>(System.Func<TState, T>! callback, TState state) -> T
Polly.ResilienceStrategy<TResult>.Execute<T>(System.Func<Polly.ResilienceContext!, T>! callback, Polly.ResilienceContext! context) -> T
Polly.ResilienceStrategy<TResult>.Execute<T>(System.Func<System.Threading.CancellationToken, T>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T
Polly.ResilienceStrategy<TResult>.Execute<T>(System.Func<T>! callback) -> T
Polly.ResilienceStrategy<TResult>.ExecuteAsync<T, TState>(System.Func<Polly.ResilienceContext!, TState, System.Threading.Tasks.ValueTask<T>>! callback, Polly.ResilienceContext! context, TState state) -> System.Threading.Tasks.ValueTask<T>
Polly.ResilienceStrategy<TResult>.ExecuteAsync<T, TState>(System.Func<TState, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, TState state, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<T>
Polly.ResilienceStrategy<TResult>.ExecuteAsync<T>(System.Func<Polly.ResilienceContext!, System.Threading.Tasks.ValueTask<T>>! callback, Polly.ResilienceContext! context) -> System.Threading.Tasks.ValueTask<T>
Polly.ResilienceStrategy<TResult>.ExecuteAsync<T>(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<T>
Polly.ResilienceStrategy<TResult>.ExecuteOutcomeAsync<T, TState>(System.Func<Polly.ResilienceContext!, TState, System.Threading.Tasks.ValueTask<Polly.Outcome<T>>>! callback, Polly.ResilienceContext! context, TState state) -> System.Threading.Tasks.ValueTask<Polly.Outcome<T>>
Polly.ResilienceStrategyBuilder
Polly.ResilienceStrategyBuilder.Build() -> Polly.ResilienceStrategy!
Polly.ResilienceStrategyBuilder.ResilienceStrategyBuilder() -> void
Expand Down
29 changes: 19 additions & 10 deletions src/Polly.Core/ResilienceStrategy.TResult.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ public partial class ResilienceStrategy<TResult>
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="context">The context associated with the callback.</param>
/// <param name="state">The state associated with the callback.</param>
/// <returns>The instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> or <paramref name="context"/> is <see langword="null"/>.</exception>
public ValueTask<TResult> ExecuteAsync<TState>(
Func<ResilienceContext, TState, ValueTask<TResult>> callback,
public ValueTask<T> ExecuteAsync<T, TState>(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a better name we can give this rather than T?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just swap T with TResult?

So it will be ResilienceStrategy<T> but individual methods will have TResult?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have any good suggestions - your one sounds fine to me.

Func<ResilienceContext, TState, ValueTask<T>> callback,
ResilienceContext context,
TState state)
where T : TResult
{
Guard.NotNull(callback);
Guard.NotNull(context);
Expand All @@ -41,13 +43,15 @@ public ValueTask<TResult> ExecuteAsync<TState>(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="context">The context associated with the callback.</param>
/// <returns>The instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> or <paramref name="context"/> is <see langword="null"/>.</exception>
public ValueTask<TResult> ExecuteAsync(
Func<ResilienceContext, ValueTask<TResult>> callback,
public ValueTask<T> ExecuteAsync<T>(
Func<ResilienceContext, ValueTask<T>> callback,
ResilienceContext context)
where T : TResult
{
Guard.NotNull(callback);
Guard.NotNull(context);
Expand All @@ -58,16 +62,18 @@ public ValueTask<TResult> ExecuteAsync(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="state">The state associated with the callback.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> associated with the callback.</param>
/// <returns>The instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public ValueTask<TResult> ExecuteAsync<TState>(
Func<TState, CancellationToken, ValueTask<TResult>> callback,
public ValueTask<T> ExecuteAsync<T, TState>(
Func<TState, CancellationToken, ValueTask<T>> callback,
TState state,
CancellationToken cancellationToken = default)
where T : TResult
{
Guard.NotNull(callback);

Expand All @@ -77,12 +83,13 @@ public ValueTask<TResult> ExecuteAsync<TState>(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> associated with the callback.</param>
/// <returns>The instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public ValueTask<TResult> ExecuteAsync(
Func<CancellationToken, ValueTask<TResult>> callback,
public ValueTask<T> ExecuteAsync<T>(
Func<CancellationToken, ValueTask<T>> callback,
CancellationToken cancellationToken = default)
{
Guard.NotNull(callback);
Expand All @@ -93,6 +100,7 @@ public ValueTask<TResult> ExecuteAsync(
/// <summary>
/// Executes the specified outcome-based callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="context">The context associated with the callback.</param>
Expand All @@ -103,10 +111,11 @@ public ValueTask<TResult> ExecuteAsync(
/// This method is for advanced and high performance scenarios. The caller must make sure that the <paramref name="callback"/>
/// does not throw any exceptions. Instead, it converts them to <see cref="Outcome{TResult}"/>.
/// </remarks>
public ValueTask<Outcome<TResult>> ExecuteOutcomeAsync<TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
public ValueTask<Outcome<T>> ExecuteOutcomeAsync<T, TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback,
ResilienceContext context,
TState state)
where T : TResult
{
Guard.NotNull(callback);
Guard.NotNull(context);
Expand Down
32 changes: 22 additions & 10 deletions src/Polly.Core/ResilienceStrategy.TResult.Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ public partial class ResilienceStrategy<TResult>
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="context">The context associated with the callback.</param>
/// <param name="state">The state associated with the callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> or <paramref name="context"/> is <see langword="null"/>.</exception>
public TResult Execute<TState>(
Func<ResilienceContext, TState, TResult> callback,
public T Execute<T, TState>(
Func<ResilienceContext, TState, T> callback,
ResilienceContext context,
TState state)
where T : TResult
{
Guard.NotNull(callback);
Guard.NotNull(context);
Expand All @@ -27,13 +29,15 @@ public TResult Execute<TState>(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="context">The context associated with the callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> or <paramref name="context"/> is <see langword="null"/>.</exception>
public TResult Execute(
Func<ResilienceContext, TResult> callback,
public T Execute<T>(
Func<ResilienceContext, T> callback,
ResilienceContext context)
where T : TResult
{
Guard.NotNull(callback);
Guard.NotNull(context);
Expand All @@ -44,13 +48,15 @@ public TResult Execute(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> associated with the callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public TResult Execute(
Func<CancellationToken, TResult> callback,
public T Execute<T>(
Func<CancellationToken, T> callback,
CancellationToken cancellationToken = default)
where T : TResult
{
Guard.NotNull(callback);

Expand All @@ -60,10 +66,12 @@ public TResult Execute(
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public TResult Execute(Func<TResult> callback)
public T Execute<T>(Func<T> callback)
where T : TResult
{
Guard.NotNull(callback);

Expand All @@ -73,12 +81,14 @@ public TResult Execute(Func<TResult> callback)
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="state">The state associated with the callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public TResult Execute<TState>(Func<TState, TResult> callback, TState state)
public T Execute<T, TState>(Func<TState, T> callback, TState state)
where T : TResult
{
Guard.NotNull(callback);

Expand All @@ -88,16 +98,18 @@ public TResult Execute<TState>(Func<TState, TResult> callback, TState state)
/// <summary>
/// Executes the specified callback.
/// </summary>
/// <typeparam name="T">The type of the result.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
/// <param name="callback">The user-provided callback.</param>
/// <param name="state">The state associated with the callback.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> associated with the callback.</param>
/// <returns>An instance of <see cref="ValueTask"/> that represents the asynchronous execution.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="callback"/> is <see langword="null"/>.</exception>
public TResult Execute<TState>(
Func<TState, CancellationToken, TResult> callback,
public T Execute<T, TState>(
Func<TState, CancellationToken, T> callback,
TState state,
CancellationToken cancellationToken = default)
where T : TResult
{
Guard.NotNull(callback);

Expand Down