Skip to content

Commit

Permalink
Use proactive term instead of non-reactive (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk authored Sep 6, 2023
1 parent 549000b commit 90b7935
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/Polly.Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ The `ResiliencePipeline` class unifies the four different policies that were ava

The resilience pipeline may consist of one or more individual resilience strategies. Polly V8 categorizes resilience strategies into the following building blocks:

- `ResilienceStrategy`: Base class for all non-reactive resilience strategies.
- `ResilienceStrategy`: Base class for all proactive resilience strategies.
- `ResilienceStrategy<T>`: Base class for all reactive resilience strategies.

### Example: Custom Non-Reactive Strategy
### Example: Custom Proactive Strategy

Here's an example of a non-reactive strategy that executes a user-provided callback:
Here's an example of a proactive strategy that executes a user-provided callback:

<!-- snippet: my-custom-strategy -->
```cs
Expand Down Expand Up @@ -157,7 +157,7 @@ public class MyCustomStrategyOptions : ResilienceStrategyOptions
To gain insights into implementing custom resilience strategies, you can explore the following Polly strategy examples:

- [**Retry**](Retry/): Demonstrates how to implement a reactive resilience strategy.
- [**Timeout**](Timeout/): Provides guidance on implementing a non-reactive resilience strategy.
- [**Timeout**](Timeout/): Provides guidance on implementing a proactive resilience strategy.
- [**Extensibility Sample**](../../samples/Extensibility/): Offers a practical example of creating a custom resilience strategy.

## Resilience Strategy Delegates
Expand All @@ -170,29 +170,28 @@ Individual resilience strategies make use of several delegate types:

Recommended signatures for these delegates are:

**Predicates**
### Predicates

- `Func<Args<TResult>, ValueTask<bool>>` (Reactive)

**Events**
### Events

- `Func<Args<TResult>, ValueTask>` (Reactive)
- `Func<Args, ValueTask>` (Non-Reactive)
- `Func<Args, ValueTask>` (Proactive)

**Generators**
### Generators

- `Func<Args<TResult>, ValueTask<TValue>>` (Reactive)
- `Func<Args, ValueTask<TValue>>` (Non-Reactive)
- `Func<Args, ValueTask<TValue>>` (Proactive)

### Delegate Arguments

These delegates accept either `Args` or `Args<TResult>` arguments, which encapsulate event information. Note that all these delegates are asynchronous and return a `ValueTask`.

> [!NOTE]
> When setting up delegates, consider using the `ResilienceContext.ContinueOnCapturedContext` property if your user code interacts with a synchronization context (as in asynchronous UI applications like Windows Forms or WPF).
### Delegate Arguments

For non-reactive strategies, the `Args` structure might resemble:
For proactive strategies, the `Args` structure might resemble:

<!-- snippet: on-timeout-args -->
```cs
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/ResiliencePipelineBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static ResiliencePipelineBuilder<TResult> AddPipeline<TResult>(this Resil
}

/// <summary>
/// Adds a non-reactive strategy to the builder.
/// Adds a proactive resilience strategy to the builder.
/// </summary>
/// <typeparam name="TBuilder">The builder type.</typeparam>
/// <param name="builder">The builder instance.</param>
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/ResilienceStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace Polly;

/// <summary>
/// Base class for all non-reactive resilience strategies.
/// Base class for all proactive resilience strategies.
/// </summary>
public abstract class ResilienceStrategy
{
/// <summary>
/// An implementation of a non-reactive resilience strategy that executes the specified <paramref name="callback"/>.
/// An implementation of a proactive resilience strategy that executes the specified <paramref name="callback"/>.
/// </summary>
/// <typeparam name="TResult">The type of result returned by the callback.</typeparam>
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
Expand Down

0 comments on commit 90b7935

Please sign in to comment.