Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polly V8: Public API Review #1233

Closed
wants to merge 16 commits into from
10 changes: 10 additions & 0 deletions ApiReview/API.Polly.Core/AssemblyDependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
System.Collections
System.Collections.Concurrent
System.ComponentModel.Annotations
System.Linq
System.Private.CoreLib
System.Private.Uri
System.Runtime
System.Runtime.CompilerServices.Unsafe
System.Runtime.InteropServices
System.Threading
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public class BrokenCircuitException<TResult> : BrokenCircuitException
{
public TResult Result { get; }
public BrokenCircuitException(TResult result);
public BrokenCircuitException(string message, TResult result);
public BrokenCircuitException(string message, Exception inner, TResult result);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Assembly 'Polly.Core'

using System;

namespace Polly.CircuitBreaker;

public class BrokenCircuitException : ExecutionRejectedException
{
public BrokenCircuitException();
public BrokenCircuitException(string message);
public BrokenCircuitException(string message, Exception inner);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Assembly 'Polly.Core'

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace Polly.CircuitBreaker;

public sealed class CircuitBreakerManualControl : IDisposable
{
public CircuitBreakerManualControl();
public CircuitBreakerManualControl(bool isIsolated);
public Task IsolateAsync(CancellationToken cancellationToken = default(CancellationToken));
martintmk marked this conversation as resolved.
Show resolved Hide resolved
public Task CloseAsync(CancellationToken cancellationToken = default(CancellationToken));
public void Dispose();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;

namespace Polly.CircuitBreaker;

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

using System;

namespace Polly.CircuitBreaker;

public sealed class CircuitBreakerStateProvider
{
public CircuitState CircuitState { get; }
public CircuitBreakerStateProvider();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Assembly 'Polly.Core'

using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Polly.CircuitBreaker;

public class CircuitBreakerStrategyOptions<TResult> : ResilienceStrategyOptions
{
[Range(0.0, 1.0)]
public double FailureRatio { get; set; }
[Range(2, int.MaxValue)]
public int MinimumThroughput { get; set; }
[Range(typeof(TimeSpan), "00:00:00.500", "1.00:00:00")]
public TimeSpan SamplingDuration { get; set; }
[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<OnCircuitHalfOpenedArguments, ValueTask>? OnHalfOpened { get; set; }
public CircuitBreakerManualControl? ManualControl { get; set; }
public CircuitBreakerStateProvider? StateProvider { get; set; }
public CircuitBreakerStrategyOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Assembly 'Polly.Core'

namespace Polly.CircuitBreaker;

public class CircuitBreakerStrategyOptions : CircuitBreakerStrategyOptions<object>
{
public CircuitBreakerStrategyOptions();
}
martintmk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Assembly 'Polly.Core'

namespace Polly.CircuitBreaker;

public enum CircuitState
{
Closed = 0,
Open = 1,
HalfOpen = 2,
Isolated = 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Assembly 'Polly.Core'

using System;

namespace Polly.CircuitBreaker;

public class IsolatedCircuitException : BrokenCircuitException
{
public IsolatedCircuitException();
public IsolatedCircuitException(string message);
public IsolatedCircuitException(string message, Exception innerException);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public readonly struct OnCircuitClosedArguments
{
public bool IsManual { get; }
public OnCircuitClosedArguments(bool isManual);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public readonly struct OnCircuitHalfOpenedArguments
{
public ResilienceContext Context { get; }
public OnCircuitHalfOpenedArguments(ResilienceContext context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public readonly struct OnCircuitOpenedArguments
{
public TimeSpan BreakDuration { get; }
public bool IsManual { get; }
public OnCircuitOpenedArguments(TimeSpan breakDuration, bool isManual);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;

namespace Polly.Fallback;

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

using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Polly.Fallback;

public class FallbackStrategyOptions<TResult> : ResilienceStrategyOptions
{
[Required]
public Func<OutcomeArguments<TResult, FallbackPredicateArguments>, 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 FallbackStrategyOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;

namespace Polly.Fallback;

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

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Polly.Hedging;

public readonly struct HedgingActionGeneratorArguments<TResult>
{
public ResilienceContext PrimaryContext { get; }
public ResilienceContext ActionContext { get; }
public int AttemptNumber { get; }
public Func<ResilienceContext, ValueTask<Outcome<TResult>>> Callback { get; }
martintmk marked this conversation as resolved.
Show resolved Hide resolved
public HedgingActionGeneratorArguments(ResilienceContext primaryContext, ResilienceContext actionContext, int attemptNumber, Func<ResilienceContext, ValueTask<Outcome<TResult>>> callback);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.Hedging;

public readonly struct HedgingDelayArguments
{
public ResilienceContext Context { get; }
public int AttemptNumber { get; }
public HedgingDelayArguments(ResilienceContext context, int attemptNumber);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Assembly 'Polly.Core'

using System.Runtime.InteropServices;

namespace Polly.Hedging;

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

using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Polly.Hedging;

public class HedgingStrategyOptions<TResult> : ResilienceStrategyOptions
{
public TimeSpan HedgingDelay { get; set; }
[Range(2, 10)]
public int MaxHedgedAttempts { get; set; }
[Required]
public Func<OutcomeArguments<TResult, HedgingPredicateArguments>, 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 HedgingStrategyOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.Hedging;

public readonly struct OnHedgingArguments
{
public int AttemptNumber { get; }
public bool HasOutcome { get; }
public TimeSpan Duration { get; }
public OnHedgingArguments(int attemptNumber, bool hasOutcome, TimeSpan duration);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Assembly 'Polly.Core'

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading;

namespace Polly.Registry;

public class ConfigureBuilderContext<TKey> where TKey : notnull
{
public TKey PipelineKey { get; }
[EditorBrowsable(EditorBrowsableState.Never)]
public void EnableReloads(Func<Func<CancellationToken>> tokenProducerFactory);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Assembly 'Polly.Core'

using System.Diagnostics.CodeAnalysis;

namespace Polly.Registry;

public abstract class ResiliencePipelineProvider<TKey> where TKey : notnull
{
public virtual ResiliencePipeline GetPipeline(TKey key);
public virtual ResiliencePipeline<TResult> GetPipeline<TResult>(TKey key);
public abstract bool TryGetPipeline(TKey key, [NotNullWhen(true)] out ResiliencePipeline? pipeline);
public abstract bool TryGetPipeline<TResult>(TKey key, [NotNullWhen(true)] out ResiliencePipeline<TResult>? pipeline);
protected ResiliencePipelineProvider();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Assembly 'Polly.Core'

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Polly.Utils;

namespace Polly.Registry;

public sealed class ResiliencePipelineRegistry<TKey> : ResiliencePipelineProvider<TKey> where TKey : notnull
{
public ResiliencePipelineRegistry();
public ResiliencePipelineRegistry(ResiliencePipelineRegistryOptions<TKey> options);
public override bool TryGetPipeline<TResult>(TKey key, [NotNullWhen(true)] out ResiliencePipeline<TResult>? pipeline);
public override bool TryGetPipeline(TKey key, [NotNullWhen(true)] out ResiliencePipeline? pipeline);
public ResiliencePipeline GetOrAddPipeline(TKey key, Action<ResiliencePipelineBuilder> configure);
public ResiliencePipeline GetOrAddPipeline(TKey key, Action<ResiliencePipelineBuilder, ConfigureBuilderContext<TKey>> configure);
public ResiliencePipeline<TResult> GetOrAddPipeline<TResult>(TKey key, Action<ResiliencePipelineBuilder<TResult>> configure);
public ResiliencePipeline<TResult> GetOrAddPipeline<TResult>(TKey key, Action<ResiliencePipelineBuilder<TResult>, ConfigureBuilderContext<TKey>> configure);
public bool TryAddBuilder(TKey key, Action<ResiliencePipelineBuilder, ConfigureBuilderContext<TKey>> configure);
public bool TryAddBuilder<TResult>(TKey key, Action<ResiliencePipelineBuilder<TResult>, ConfigureBuilderContext<TKey>> configure);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Assembly 'Polly.Core'

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;

namespace Polly.Registry;

public class ResiliencePipelineRegistryOptions<TKey>
{
[Required]
public Func<ResiliencePipelineBuilder> BuilderFactory { get; set; }
[Required]
public IEqualityComparer<TKey> PipelineComparer { get; set; }
[Required]
public IEqualityComparer<TKey> BuilderComparer { get; set; }
public Func<TKey, string>? InstanceNameFormatter { get; set; }
[Required]
public Func<TKey, string> BuilderNameFormatter { get; set; }
public ResiliencePipelineRegistryOptions();
}
14 changes: 14 additions & 0 deletions ApiReview/API.Polly.Core/NoDocs/Polly.Retry/OnRetryArguments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.Retry;

public readonly struct OnRetryArguments
{
public int AttemptNumber { get; }
public TimeSpan RetryDelay { get; }
public TimeSpan ExecutionTime { get; }
public OnRetryArguments(int attemptNumber, TimeSpan retryDelay, TimeSpan executionTime);
}
Loading
Loading