Skip to content

Commit

Permalink
Update with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Aug 24, 2023
1 parent ed62938 commit 4804c22
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.CircuitBreaker;

public readonly struct CircuitBreakerPredicateArguments
public readonly struct CircuitBreakerPredicateArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public CircuitBreakerPredicateArguments(ResilienceContext context, Outcome<TResult> outcome);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class CircuitBreakerStrategyOptions<TResult> : ResilienceStrategyOptions
[Range(typeof(TimeSpan), "00:00:00.500", "1.00:00:00")]
public TimeSpan BreakDuration { get; set; }
[Required]
public Func<OutcomeArguments<TResult, CircuitBreakerPredicateArguments>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<OutcomeArguments<TResult, OnCircuitClosedArguments>, ValueTask>? OnClosed { get; set; }
public Func<OutcomeArguments<TResult, OnCircuitOpenedArguments>, ValueTask>? OnOpened { get; set; }
public Func<CircuitBreakerPredicateArguments<TResult>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<OnCircuitClosedArguments<TResult>, ValueTask>? OnClosed { get; set; }
public Func<OnCircuitOpenedArguments<TResult>, ValueTask>? OnOpened { get; set; }
public Func<OnCircuitHalfOpenedArguments, ValueTask>? OnHalfOpened { get; set; }
public CircuitBreakerManualControl? ManualControl { get; set; }
public CircuitBreakerStateProvider? StateProvider { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.CircuitBreaker;

public readonly struct OnCircuitClosedArguments
public readonly struct OnCircuitClosedArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public bool IsManual { get; }
public OnCircuitClosedArguments(bool isManual);
public OnCircuitClosedArguments(ResilienceContext context, Outcome<TResult> outcome, bool isManual);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

using System;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.CircuitBreaker;

public readonly struct OnCircuitOpenedArguments
public readonly struct OnCircuitOpenedArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public TimeSpan BreakDuration { get; }
public bool IsManual { get; }
public OnCircuitOpenedArguments(TimeSpan breakDuration, bool isManual);
public OnCircuitOpenedArguments(ResilienceContext context, Outcome<TResult> outcome, TimeSpan breakDuration, bool isManual);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Fallback;

public readonly struct FallbackPredicateArguments
public readonly struct FallbackPredicateArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public FallbackPredicateArguments(ResilienceContext context, Outcome<TResult> outcome);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Polly.Fallback;
public class FallbackStrategyOptions<TResult> : ResilienceStrategyOptions
{
[Required]
public Func<OutcomeArguments<TResult, FallbackPredicateArguments>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<FallbackPredicateArguments<TResult>, ValueTask<bool>> ShouldHandle { get; set; }
[Required]
public Func<OutcomeArguments<TResult, FallbackPredicateArguments>, ValueTask<Outcome<TResult>>>? FallbackAction { get; set; }
public Func<OutcomeArguments<TResult, OnFallbackArguments>, ValueTask>? OnFallback { get; set; }
public Func<FallbackPredicateArguments<TResult>, ValueTask<Outcome<TResult>>>? FallbackAction { get; set; }
public Func<OnFallbackArguments<TResult>, ValueTask>? OnFallback { get; set; }
public FallbackStrategyOptions();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Fallback;

[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly struct OnFallbackArguments
public readonly struct OnFallbackArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public OnFallbackArguments(ResilienceContext context, Outcome<TResult> outcome);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Hedging;

public readonly struct HedgingPredicateArguments
public readonly struct HedgingPredicateArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public HedgingPredicateArguments(ResilienceContext context, Outcome<TResult> outcome);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class HedgingStrategyOptions<TResult> : ResilienceStrategyOptions
[Range(2, 10)]
public int MaxHedgedAttempts { get; set; }
[Required]
public Func<OutcomeArguments<TResult, HedgingPredicateArguments>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<HedgingPredicateArguments<TResult>, ValueTask<bool>> ShouldHandle { get; set; }
[Required]
public Func<HedgingActionGeneratorArguments<TResult>, Func<ValueTask<Outcome<TResult>>>?> HedgingActionGenerator { get; set; }
public Func<HedgingDelayArguments, ValueTask<TimeSpan>>? HedgingDelayGenerator { get; set; }
public Func<OutcomeArguments<TResult, OnHedgingArguments>, ValueTask>? OnHedging { get; set; }
public Func<OnHedgingArguments<TResult>, ValueTask>? OnHedging { get; set; }
public HedgingStrategyOptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

using System;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Hedging;

public readonly struct OnHedgingArguments
public readonly struct OnHedgingArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public int AttemptNumber { get; }
public bool HasOutcome { get; }
public TimeSpan Duration { get; }
public OnHedgingArguments(int attemptNumber, bool hasOutcome, TimeSpan duration);
public OnHedgingArguments(ResilienceContext context, Outcome<TResult> outcome, int attemptNumber, bool hasOutcome, TimeSpan duration);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Assembly 'Polly.Core'

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading;
Expand All @@ -11,5 +12,6 @@ public class ConfigureBuilderContext<TKey> where TKey : notnull
{
public TKey PipelineKey { get; }
[EditorBrowsable(EditorBrowsableState.Never)]
public void EnableReloads(Func<Func<CancellationToken>> tokenProducerFactory);
public void AddReloadToken(CancellationToken cancellationToken);
public void OnPipelineDisposed(Action callback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Polly.Utils.Pipeline;

namespace Polly.Registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

using System;
using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Retry;

public readonly struct OnRetryArguments
public readonly struct OnRetryArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public int AttemptNumber { get; }
public TimeSpan RetryDelay { get; }
public TimeSpan ExecutionTime { get; }
public OnRetryArguments(int attemptNumber, TimeSpan retryDelay, TimeSpan executionTime);
public TimeSpan Duration { get; }
public OnRetryArguments(ResilienceContext context, Outcome<TResult> outcome, int attemptNumber, TimeSpan retryDelay, TimeSpan duration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

namespace Polly.Retry;

public readonly struct RetryDelayArguments
public readonly struct RetryDelayArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public int AttemptNumber { get; }
public TimeSpan DelayHint { get; }
public RetryDelayArguments(int attemptNumber, TimeSpan delayHint);
public RetryDelayArguments(ResilienceContext context, Outcome<TResult> outcome, int attemptNumber, TimeSpan delayHint);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Retry;

public readonly struct RetryPredicateArguments
public readonly struct RetryPredicateArguments<TResult>
{
public Outcome<TResult> Outcome { get; }
public ResilienceContext Context { get; }
public int AttemptNumber { get; }
public RetryPredicateArguments(int attemptNumber);
public RetryPredicateArguments(ResilienceContext context, Outcome<TResult> outcome, int attemptNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class RetryStrategyOptions<TResult> : ResilienceStrategyOptions
[Range(typeof(TimeSpan), "00:00:00", "1.00:00:00")]
public TimeSpan BaseDelay { get; set; }
[Required]
public Func<OutcomeArguments<TResult, RetryPredicateArguments>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<OutcomeArguments<TResult, RetryDelayArguments>, ValueTask<TimeSpan>>? RetryDelayGenerator { get; set; }
public Func<OutcomeArguments<TResult, OnRetryArguments>, ValueTask>? OnRetry { get; set; }
public Func<RetryPredicateArguments<TResult>, ValueTask<bool>> ShouldHandle { get; set; }
public Func<RetryDelayArguments<TResult>, ValueTask<TimeSpan>>? RetryDelayGenerator { get; set; }
public Func<OnRetryArguments<TResult>, ValueTask>? OnRetry { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
[Required]
public Func<double> Randomizer { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Polly.Telemetry;

[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly struct PipelineExecutingArguments
{
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;
using Polly.Utils;

namespace Polly.Telemetry;

public sealed class ResilienceStrategyTelemetry
{
public void Report<TArgs>(ResilienceEvent resilienceEvent, ResilienceContext context, TArgs args);
public void Report<TArgs, TResult>(ResilienceEvent resilienceEvent, OutcomeArguments<TResult, TArgs> args);
public void Report<TArgs, TResult>(ResilienceEvent resilienceEvent, ResilienceContext context, Outcome<TResult> outcome, TArgs args);
}
16 changes: 0 additions & 16 deletions ApiReview/API.Polly.Core/NoDocs/Polly/OutcomeArguments.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
using Polly.Fallback;
using Polly.Hedging;
using Polly.Retry;
using Polly.Utils;

namespace Polly;

public class PredicateBuilder<TResult>
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static implicit operator Func<OutcomeArguments<TResult, RetryPredicateArguments>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
public static implicit operator Func<RetryPredicateArguments<TResult>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
[EditorBrowsable(EditorBrowsableState.Never)]
public static implicit operator Func<OutcomeArguments<TResult, HedgingPredicateArguments>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
public static implicit operator Func<HedgingPredicateArguments<TResult>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
[EditorBrowsable(EditorBrowsableState.Never)]
public static implicit operator Func<OutcomeArguments<TResult, FallbackPredicateArguments>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
public static implicit operator Func<FallbackPredicateArguments<TResult>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
[EditorBrowsable(EditorBrowsableState.Never)]
public static implicit operator Func<OutcomeArguments<TResult, CircuitBreakerPredicateArguments>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
public static implicit operator Func<CircuitBreakerPredicateArguments<TResult>, ValueTask<bool>>(PredicateBuilder<TResult> builder);
public PredicateBuilder<TResult> Handle<TException>() where TException : Exception;
public PredicateBuilder<TResult> Handle<TException>(Func<TException, bool> predicate) where TException : Exception;
public PredicateBuilder<TResult> HandleInner<TException>() where TException : Exception;
public PredicateBuilder<TResult> HandleInner<TException>(Func<TException, bool> predicate) where TException : Exception;
public PredicateBuilder<TResult> HandleResult(Func<TResult, bool> predicate);
public PredicateBuilder<TResult> HandleResult(TResult result, IEqualityComparer<TResult>? comparer = null);
public Predicate<Outcome<TResult>> Build();
public Func<OutcomeArguments<TResult, TArgs>, ValueTask<bool>> Build<TArgs>();
public PredicateBuilder();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public sealed class AddResiliencePipelineContext<TKey> where TKey : notnull
public IServiceProvider ServiceProvider { get; }
public void EnableReloads<TOptions>(string? name = null);
public TOptions GetOptions<TOptions>(string? name = null);
public void OnPipelineDisposed(Action callback);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Assembly 'Polly.RateLimiting'

using System.Runtime.CompilerServices;

namespace Polly.RateLimiting;

public readonly struct RateLimiterArguments
{
public ResilienceContext Context { get; }
public RateLimiterArguments(ResilienceContext context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class RateLimiterStrategyOptions : ResilienceStrategyOptions
[Required]
public ConcurrencyLimiterOptions DefaultRateLimiterOptions { get; set; }
public Func<OnRateLimiterRejectedArguments, ValueTask>? OnRejected { get; set; }
public ResilienceRateLimiter? RateLimiter { get; set; }
public Func<RateLimiterArguments, ValueTask<RateLimitLease>>? RateLimiter { get; set; }
public RateLimiterStrategyOptions();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ public sealed class ResiliencePipelineDescriptor
public IReadOnlyList<ResilienceStrategyDescriptor> Strategies { get; }
public ResilienceStrategyDescriptor FirstStrategy { get; }
public bool IsReloadable { get; }
public ResiliencePipelineDescriptor(IReadOnlyList<ResilienceStrategyDescriptor> strategies, bool isReloadable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ public sealed class ResilienceStrategyDescriptor
{
public ResilienceStrategyOptions? Options { get; }
public object StrategyInstance { get; }
public ResilienceStrategyDescriptor(ResilienceStrategyOptions? options, object strategyInstance);
}

0 comments on commit 4804c22

Please sign in to comment.