Skip to content

Commit b9ce232

Browse files
authored
Rename ExecuteCoreAsync to ExecuteCore (#1424)
1 parent 7199f75 commit b9ce232

23 files changed

+49
-45
lines changed

bench/Polly.Core.Benchmarks/TelemetryBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private class TelemetryEventStrategy : ResilienceStrategy
7373

7474
public TelemetryEventStrategy(ResilienceStrategyTelemetry telemetry) => _telemetry = telemetry;
7575

76-
protected override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
76+
protected override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
7777
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
7878
ResilienceContext context,
7979
TState state)

bench/Polly.Core.Benchmarks/Utils/EmptyResilienceStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Polly.Core.Benchmarks.Utils;
22

33
internal class EmptyResilienceStrategy : ResilienceStrategy
44
{
5-
protected override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
5+
protected override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
66
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
77
ResilienceContext context,
88
TState state)

bench/Polly.Core.Benchmarks/Utils/Helper.CircuitBreaker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static object CreateCircuitBreaker(PollyVersion technology)
6666

6767
private class OutcomeHandlingStrategy : ResilienceStrategy
6868
{
69-
protected override async ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
69+
protected override async ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
7070
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
7171
ResilienceContext context,
7272
TState state)

src/Polly.Core/NullResilienceStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private NullResilienceStrategy()
1515
}
1616

1717
/// <inheritdoc/>
18-
protected internal override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
18+
protected internal override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
1919
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
2020
ResilienceContext context,
2121
TState state)

src/Polly.Core/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ abstract Polly.Registry.ResilienceStrategyProvider<TKey>.TryGetStrategy(TKey key
33
abstract Polly.Registry.ResilienceStrategyProvider<TKey>.TryGetStrategy<TResult>(TKey key, out Polly.ResilienceStrategy<TResult>? strategy) -> bool
44
abstract Polly.ResilienceContextPool.Get(string? operationKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Polly.ResilienceContext!
55
abstract Polly.ResilienceContextPool.Return(Polly.ResilienceContext! context) -> void
6-
abstract Polly.ResilienceStrategy.ExecuteCoreAsync<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>>
6+
abstract Polly.ResilienceStrategy.ExecuteCore<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>>
77
override Polly.Outcome<TResult>.ToString() -> string!
88
override Polly.Registry.ResilienceStrategyRegistry<TKey>.TryGetStrategy(TKey key, out Polly.ResilienceStrategy? strategy) -> bool
99
override Polly.Registry.ResilienceStrategyRegistry<TKey>.TryGetStrategy<TResult>(TKey key, out Polly.ResilienceStrategy<TResult>? strategy) -> bool

src/Polly.Core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void Execute(Action execute)
7373

7474
try
7575
{
76-
strategy.ExecuteCoreAsync(static (context, state) =>
76+
strategy.ExecuteAsync(static (context, state) =>
7777
{
7878
state();
7979
return new ValueTask<Outcome<VoidResult>>(new(VoidResult.Instance));
@@ -108,7 +108,7 @@ internal class DelayStrategy : ResilienceStrategy
108108
_timeProvider = timeProvider;
109109
}
110110

111-
protected override async ValueTask<T> ExecuteCoreAsync<T, TState>(
111+
protected override async ValueTask<T> ExecuteCore<T, TState>(
112112
Func<ResilienceContext, TState, ValueTask<Outcome<T>>> callback,
113113
ResilienceContext context,
114114
TState state)

src/Polly.Core/ResilienceStrategy.Async.ValueTask.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async ValueTask ExecuteAsync<TState>(
2424

2525
InitializeAsyncContext(context);
2626

27-
var outcome = await ExecuteCoreAsync(
27+
var outcome = await ExecuteCore(
2828
static async (context, state) =>
2929
{
3030
try
@@ -59,7 +59,7 @@ public async ValueTask ExecuteAsync(
5959

6060
InitializeAsyncContext(context);
6161

62-
var outcome = await ExecuteCoreAsync(
62+
var outcome = await ExecuteCore(
6363
static async (context, state) =>
6464
{
6565
try
@@ -98,7 +98,7 @@ public async ValueTask ExecuteAsync<TState>(
9898

9999
try
100100
{
101-
var outcome = await ExecuteCoreAsync(
101+
var outcome = await ExecuteCore(
102102
static async (context, state) =>
103103
{
104104
try
@@ -139,7 +139,7 @@ public async ValueTask ExecuteAsync(
139139

140140
try
141141
{
142-
var outcome = await ExecuteCoreAsync(
142+
var outcome = await ExecuteCore(
143143
static async (context, state) =>
144144
{
145145
try

src/Polly.Core/ResilienceStrategy.Async.ValueTaskT.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ValueTask<Outcome<TResult>> ExecuteOutcomeAsync<TResult, TState>(
2929

3030
InitializeAsyncContext<TResult>(context);
3131

32-
return ExecuteCoreAsync(callback, context, state);
32+
return ExecuteCore(callback, context, state);
3333
}
3434

3535
/// <summary>
@@ -52,7 +52,7 @@ public async ValueTask<TResult> ExecuteAsync<TResult, TState>(
5252

5353
InitializeAsyncContext<TResult>(context);
5454

55-
var outcome = await ExecuteCoreAsync(
55+
var outcome = await ExecuteCore(
5656
static async (context, state) =>
5757
{
5858
try
@@ -87,7 +87,7 @@ public async ValueTask<TResult> ExecuteAsync<TResult>(
8787

8888
InitializeAsyncContext<TResult>(context);
8989

90-
var outcome = await ExecuteCoreAsync(
90+
var outcome = await ExecuteCore(
9191
static async (context, state) =>
9292
{
9393
try
@@ -126,7 +126,7 @@ public async ValueTask<TResult> ExecuteAsync<TResult, TState>(
126126

127127
try
128128
{
129-
var outcome = await ExecuteCoreAsync(
129+
var outcome = await ExecuteCore(
130130
static async (context, state) =>
131131
{
132132
try
@@ -167,7 +167,7 @@ public async ValueTask<TResult> ExecuteAsync<TResult>(
167167

168168
try
169169
{
170-
var outcome = await ExecuteCoreAsync(
170+
var outcome = await ExecuteCore(
171171
static async (context, state) =>
172172
{
173173
try

src/Polly.Core/ResilienceStrategy.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@ public abstract partial class ResilienceStrategy
1616
internal ResilienceStrategyOptions? Options { get; set; }
1717

1818
/// <summary>
19-
/// Executes the specified callback.
19+
/// An implementation of resilience strategy that executes the specified <paramref name="callback"/>.
2020
/// </summary>
2121
/// <typeparam name="TResult">The type of result returned by the callback.</typeparam>
2222
/// <typeparam name="TState">The type of state associated with the callback.</typeparam>
2323
/// <param name="callback">The user-provided callback.</param>
2424
/// <param name="context">The context associated with the callback.</param>
2525
/// <param name="state">The state associated with the callback.</param>
26-
/// <returns>An instance of <see cref="ValueTask"/> that represents an asynchronous callback.</returns>
26+
/// <returns>
27+
/// An instance of pending <see cref="ValueTask"/> for asynchronous executions or completed <see cref="ValueTask"/> task for synchronous exexutions.
28+
/// </returns>
2729
/// <remarks>
28-
/// This method is called by various methods exposed on <see cref="ResilienceStrategy"/>. These methods make sure that
29-
/// <paramref name="context"/> is properly initialized with details about the execution mode.
30+
/// <strong>This method is called for both synchronous and asynchronous execution flows.</strong>
3031
/// <para>
31-
/// The provided callback never throws an exception. Instead, the exception is captured and converted to an <see cref="Outcome{TResult}"/>.
32+
/// You can use <see cref="ResilienceContext.IsSynchronous"/> to dermine wheether the <paramref name="callback"/> is synchronous or asynchronous one.
33+
/// This is useful when the custom strategy behaves differently in each execution flow. In general, for most strategies, the implementation
34+
/// is the same for both execution flows.
3235
/// </para>
3336
/// <para>
34-
/// Do not throw exceptions from your strategy implementation. Instead, return an exception instance as <see cref="Outcome{TResult}"/>.
37+
/// The provided callback never throws an exception. Instead, the exception is captured and converted to an <see cref="Outcome{TResult}"/>.
38+
/// Similarly, do not throw exceptions from your strategy implementation. Instead, return an exception instance as <see cref="Outcome{TResult}"/>.
3539
/// </para>
3640
/// </remarks>
37-
protected internal abstract ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
41+
protected internal abstract ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
3842
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
3943
ResilienceContext context,
4044
TState state);
@@ -44,7 +48,7 @@ private Outcome<TResult> ExecuteCoreSync<TResult, TState>(
4448
ResilienceContext context,
4549
TState state)
4650
{
47-
return ExecuteCoreAsync(
51+
return ExecuteCore(
4852
static (context, state) =>
4953
{
5054
var result = state.callback(context, state.state);

src/Polly.Core/Timeout/TimeoutResilienceStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public TimeoutResilienceStrategy(TimeoutStrategyOptions options, TimeProvider ti
2222

2323
public Func<OnTimeoutArguments, ValueTask>? OnTimeout { get; }
2424

25-
protected internal override async ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(
25+
protected internal override async ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
2626
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
2727
ResilienceContext context,
2828
TState state)

0 commit comments

Comments
 (0)