-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some internals into
Pipeline
folder (#1497)
- Loading branch information
Showing
36 changed files
with
498 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using Polly.Utils.Pipeline; | ||
|
||
namespace Polly; | ||
|
||
/// <summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Polly.Utils.Pipeline; | ||
|
||
[DebuggerDisplay("{Strategy}")] | ||
internal sealed class BridgeComponent<T> : BridgeComponentBase | ||
{ | ||
public BridgeComponent(ResilienceStrategy<T> strategy) | ||
: base(strategy) => Strategy = strategy; | ||
|
||
public ResilienceStrategy<T> Strategy { get; } | ||
|
||
internal override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>( | ||
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, | ||
ResilienceContext context, | ||
TState state) | ||
{ | ||
// Check if we can cast directly, thus saving some cycles and improving the performance | ||
if (callback is Func<ResilienceContext, TState, ValueTask<Outcome<T>>> casted) | ||
{ | ||
return TaskHelper.ConvertValueTask<T, TResult>( | ||
Strategy.ExecuteCore(casted, context, state), | ||
context); | ||
} | ||
else | ||
{ | ||
var valueTask = Strategy.ExecuteCore( | ||
static async (context, state) => | ||
{ | ||
var outcome = await state.callback(context, state.state).ConfigureAwait(context.ContinueOnCapturedContext); | ||
return outcome.AsOutcome<T>(); | ||
}, | ||
context, | ||
(callback, state)); | ||
|
||
return TaskHelper.ConvertValueTask<T, TResult>(valueTask, context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Polly.Utils.Pipeline; | ||
|
||
[DebuggerDisplay("{Strategy}")] | ||
internal sealed class BridgeComponent : BridgeComponentBase | ||
{ | ||
public BridgeComponent(ResilienceStrategy strategy) | ||
: base(strategy) => Strategy = strategy; | ||
|
||
public ResilienceStrategy Strategy { get; } | ||
|
||
internal override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>( | ||
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, | ||
ResilienceContext context, | ||
TState state) => Strategy.ExecuteCore(callback, context, state); | ||
} |
Oops, something went wrong.