Skip to content

Commit

Permalink
Fix samples
Browse files Browse the repository at this point in the history
- Rename `ExecuteCoreAsync` to `ExecuteCore`.
- Remove `StrategyType`.
  • Loading branch information
martincostello committed Jul 26, 2023
1 parent f23c025 commit 0604b5e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions samples/Extensibility/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

internal class MySimpleStrategy : ResilienceStrategy
{
protected override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
protected override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
ResilienceContext context,
TState state)
{
Console.WriteLine("MySimpleStrategy executing!");

Expand Down Expand Up @@ -64,8 +67,6 @@ protected override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>
// 1.B Define the options.
public class MyResilienceStrategyOptions : ResilienceStrategyOptions
{
public override string StrategyType => "MyCustomStrategy";

// Use the arguments in the delegates.
// The recommendation is to use asynchronous delegates.
public Func<OnCustomEventArguments, ValueTask>? OnCustomEvent { get; set; }
Expand All @@ -87,7 +88,10 @@ public MyResilienceStrategy(ResilienceStrategyTelemetry telemetry, MyResilienceS
this.onCustomEvent = options.OnCustomEvent;
}

protected override async ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
protected override async ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback,
ResilienceContext context,
TState state)
{
// Here, do something before callback execution
// ...
Expand Down Expand Up @@ -129,5 +133,3 @@ public static TBuilder AddMyResilienceStrategy<TBuilder>(this TBuilder builder,
// Pass the options, note that the options instance is automatically validated by the builder
options);
}


0 comments on commit 0604b5e

Please sign in to comment.