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 Jul 24, 2023
1 parent 62b2eae commit e6b2c3f
Show file tree
Hide file tree
Showing 49 changed files with 158 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Polly.CircuitBreaker;

[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly record struct CircuitBreakerPredicateArguments
public readonly struct CircuitBreakerPredicateArguments
{
public CircuitBreakerPredicateArguments();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Polly.CircuitBreaker;

public abstract class CircuitBreakerStrategyOptions<TResult> : ResilienceStrategyOptions
{
public sealed override string StrategyType { get; }
[Range(typeof(TimeSpan), "00:00:00.500", "1.00:00:00")]
public TimeSpan BreakDuration { get; set; }
[Required]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public record OnCircuitClosedArguments(bool IsManual)
public sealed class OnCircuitClosedArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public bool IsManual { get; }
public OnCircuitClosedArguments(bool isManual);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.CircuitBreaker;

public record OnCircuitHalfOpenedArguments
public sealed class OnCircuitHalfOpenedArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public OnCircuitHalfOpenedArguments();
public ResilienceContext Context { get; }
public OnCircuitHalfOpenedArguments(ResilienceContext context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

namespace Polly.CircuitBreaker;

public record OnCircuitOpenedArguments(TimeSpan BreakDuration, bool IsManual)
public sealed class OnCircuitOpenedArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public TimeSpan BreakDuration { get; }
public bool IsManual { get; }
public OnCircuitOpenedArguments(TimeSpan breakDuration, bool isManual);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Polly.Fallback;

[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly record struct FallbackPredicateArguments
public readonly struct FallbackPredicateArguments
{
public FallbackPredicateArguments();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Polly.Fallback;

public class FallbackStrategyOptions<TResult> : ResilienceStrategyOptions
{
public sealed override string StrategyType { get; }
[Required]
public Func<OutcomeArguments<TResult, FallbackPredicateArguments>, ValueTask<bool>> ShouldHandle { get; set; }
[Required]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.Fallback;

public record OnFallbackArguments
public sealed class OnFallbackArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public OnFallbackArguments();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// Assembly 'Polly.Core'

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

namespace Polly.Hedging;

public readonly record struct HedgingActionGeneratorArguments<TResult>(ResilienceContext PrimaryContext, ResilienceContext ActionContext, int Attempt, Func<ResilienceContext, ValueTask<Outcome<TResult>>> Callback);
public readonly struct HedgingActionGeneratorArguments<TResult>
{
public ResilienceContext PrimaryContext { get; }
public ResilienceContext ActionContext { get; }
public int Attempt { get; }
public Func<ResilienceContext, ValueTask<Outcome<TResult>>> Callback { get; }
public HedgingActionGeneratorArguments(ResilienceContext primaryContext, ResilienceContext actionContext, int attempt, Func<ResilienceContext, ValueTask<Outcome<TResult>>> callback);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.Hedging;

public readonly record struct HedgingDelayArguments(ResilienceContext Context, int Attempt);
public readonly struct HedgingDelayArguments
{
public ResilienceContext Context { get; }
public int Attempt { get; }
public HedgingDelayArguments(ResilienceContext context, int attempt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Polly.Hedging;

[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly record struct HedgingPredicateArguments
public readonly struct HedgingPredicateArguments
{
public HedgingPredicateArguments();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Polly.Hedging;

public class HedgingStrategyOptions<TResult> : ResilienceStrategyOptions
{
public sealed override string StrategyType { get; }
public TimeSpan HedgingDelay { get; set; }
[Range(2, 10)]
public int MaxHedgedAttempts { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace Polly.Hedging;

public record OnHedgingArguments(int Attempt, bool HasOutcome, TimeSpan ExecutionTime)
public sealed class OnHedgingArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public int Attempt { get; }
public bool HasOutcome { get; }
public TimeSpan ExecutionTime { get; }
public OnHedgingArguments(int attempt, bool hasOutcome, TimeSpan executionTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace Polly.Retry;

public record OnRetryArguments(int Attempt, TimeSpan RetryDelay, TimeSpan ExecutionTime)
public sealed class OnRetryArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public int Attempt { get; }
public TimeSpan RetryDelay { get; }
public TimeSpan ExecutionTime { get; }
public OnRetryArguments(int attempt, TimeSpan retryDelay, TimeSpan executionTime);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.Retry;

public readonly record struct RetryDelayArguments(int Attempt, TimeSpan DelayHint);
public readonly struct RetryDelayArguments
{
public int Attempt { get; }
public TimeSpan DelayHint { get; }
public RetryDelayArguments(int attempt, TimeSpan delayHint);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.Retry;

public readonly record struct RetryPredicateArguments(int Attempt);
public readonly struct RetryPredicateArguments
{
public int Attempt { get; }
public RetryPredicateArguments(int attempt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace Polly.Retry;

public class RetryStrategyOptions<TResult> : ResilienceStrategyOptions
{
public sealed override string StrategyType { get; }
[Range(-1, 100)]
[Range(1, int.MaxValue)]
public int RetryCount { get; set; }
public RetryBackoffType BackoffType { get; set; }
[Range(typeof(TimeSpan), "00:00:00", "1.00:00:00")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ namespace Polly.Retry;

public class RetryStrategyOptions : RetryStrategyOptions<object>
{
public const int InfiniteRetryCount = -1;
public RetryStrategyOptions();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.Telemetry;

public readonly record struct ResilienceEvent(ResilienceEventSeverity Severity, string EventName)
public readonly struct ResilienceEvent
{
public ResilienceEventSeverity Severity { get; }
public string EventName { get; }
public ResilienceEvent(ResilienceEventSeverity severity, string eventName);
public override string ToString();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Assembly 'Polly.Core'

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Polly.Telemetry;

public sealed class ResilienceStrategyTelemetry
{
public bool IsEnabled { get; }
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Reflection is not used when consuming the event.")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Reflection is not used when consuming the event.")]
public void Report<TArgs>(ResilienceEvent resilienceEvent, ResilienceContext context, TArgs args);
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Reflection is not used when consuming the event.")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Reflection is not used when consuming the event.")]
public void Report<TArgs, TResult>(ResilienceEvent resilienceEvent, OutcomeArguments<TResult, TArgs> args);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Assembly 'Polly.Core'

using System;
using System.Runtime.CompilerServices;

namespace Polly.Telemetry;

public sealed record ResilienceTelemetrySource(string? BuilderName, string? BuilderInstanceName, ResilienceProperties BuilderProperties, string? StrategyName, string StrategyType);
public sealed class ResilienceTelemetrySource
{
public string? BuilderName { get; }
public string? BuilderInstanceName { get; }
public ResilienceProperties BuilderProperties { get; }
public string? StrategyName { get; }
public ResilienceTelemetrySource(string? builderName, string? builderInstanceName, ResilienceProperties builderProperties, string? strategyName);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Assembly 'Polly.Core'

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

namespace Polly.Telemetry;

public sealed record TelemetryEventArguments
public sealed class TelemetryEventArguments
{
public ResilienceTelemetrySource Source { get; }
public ResilienceEvent Event { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

namespace Polly.Timeout;

public record OnTimeoutArguments(ResilienceContext Context, Exception Exception, TimeSpan Timeout)
public sealed class OnTimeoutArguments
{
[CompilerGenerated]
protected virtual Type EqualityContract { get; }
public ResilienceContext Context { get; }
public Exception Exception { get; }
public TimeSpan Timeout { get; }
public OnTimeoutArguments(ResilienceContext context, Exception exception, TimeSpan timeout);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Assembly 'Polly.Core'

using System.Runtime.CompilerServices;

namespace Polly.Timeout;

public readonly record struct TimeoutGeneratorArguments(ResilienceContext Context);
public readonly struct TimeoutGeneratorArguments
{
public ResilienceContext Context { get; }
public TimeoutGeneratorArguments(ResilienceContext context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Polly.Timeout;

public class TimeoutStrategyOptions : ResilienceStrategyOptions
{
public sealed override string StrategyType { get; }
[Range(typeof(TimeSpan), "00:00:01", "1.00:00:00")]
public TimeSpan Timeout { get; set; }
public Func<TimeoutGeneratorArguments, ValueTask<TimeSpan>>? TimeoutGenerator { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Assembly 'Polly.Core'

using System.Diagnostics.CodeAnalysis;
using Polly.CircuitBreaker;

namespace Polly;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Assembly 'Polly.Core'

using System.Diagnostics.CodeAnalysis;
using Polly.Fallback;

namespace Polly;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Assembly 'Polly.Core'

using System.Diagnostics.CodeAnalysis;
using Polly.Hedging;

namespace Polly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace Polly;
public sealed class NullResilienceStrategy : ResilienceStrategy
{
public static readonly NullResilienceStrategy Instance;
protected internal override ValueTask<Outcome<TResult>> ExecuteCoreAsync<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state);
protected internal override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state);
}
6 changes: 1 addition & 5 deletions ApiReview/API.Polly.Core/NoDocs/Polly/ResilienceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@
using System.Runtime.CompilerServices;
using System.Threading;
using Polly.Telemetry;
using Polly.Utils;

namespace Polly;

public sealed class ResilienceContext
{
public string? OperationKey { get; }
public CancellationToken CancellationToken { get; set; }
public CancellationToken CancellationToken { get; }
public bool IsSynchronous { get; }
public Type ResultType { get; }
public bool IsVoid { get; }
public bool ContinueOnCapturedContext { get; set; }
public ResilienceProperties Properties { get; }
public IReadOnlyList<ResilienceEvent> ResilienceEvents { get; }
public static ResilienceContext Get(CancellationToken cancellationToken = default(CancellationToken));
public static ResilienceContext Get(string operationKey, CancellationToken cancellationToken = default(CancellationToken));
public static void Return(ResilienceContext context);
}
16 changes: 16 additions & 0 deletions ApiReview/API.Polly.Core/NoDocs/Polly/ResilienceContextPool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Assembly 'Polly.Core'

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

namespace Polly;

public abstract class ResilienceContextPool
{
public static ResilienceContextPool Shared { get; }
public ResilienceContext Get(CancellationToken cancellationToken = default(CancellationToken));
public abstract ResilienceContext Get(string? operationKey, CancellationToken cancellationToken = default(CancellationToken));
public abstract void Return(ResilienceContext context);
protected ResilienceContextPool();
}
Loading

0 comments on commit e6b2c3f

Please sign in to comment.