text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>#nullable enable namespace Polly.NoOp; /// <summary> /// A no op policy that can be applied to delegates. /// </summary> public class NoOpPolicy : Policy, INoOpPolicy { internal NoOpPolicy() { } /// <inheritdoc/> [DebuggerStepThrough] protected override TResult Implementation<TR...
fim
App-vNext/Polly
csharp
<|fim_suffix|>pPolicy NoOp() => new(); } <|fim_prefix|>#nullable enable namespace Polly; public partial class Policy { /// <summary> /// <|fim_middle|>Builds a NoOp <see cref="Policy"/> that will execute without any custom behavior. /// </summary> /// <returns>The policy instance.</returns> public...
fim
App-vNext/Polly
csharp
<|fim_suffix|> public static NoOpPolicy<TResult> NoOp<TResult>() => new(); } <|fim_prefix|>#nullable enable namespace Polly; p<|fim_middle|>ublic partial class Policy { /// <summary> /// Builds a NoOp <see cref="Policy{TResult}"/> that will execute without any custom behavior. /// </summary> /// <...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class Policy { /// <summary> /// Sets the PolicyKey for this <see cref="Policy"/> instance. /// <remarks>Must be called before the policy is first used. Can only be set once.</remarks> /// </summary> /// <param name="policyKey">The unique, us...
fim
App-vNext/Polly
csharp
<|fim_suffix|> } #region Overloads method-generic in TResult /// <summary> /// Executes the specified action within the policy and returns the captured result. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="action">The action to perform.</...
fim
App-vNext/Polly
csharp
<|fim_suffix|>/// <typeparam name="TException">The type of the exception to handle.</typeparam> /// <returns>The PolicyBuilder instance, for fluent chaining.</returns> public static PolicyBuilder<TResult> HandleInner<TException>() where TException : Exception => new(PolicyBuilder.HandleI...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class Policy<TResult> { /// <summary> /// Defines the implementation of a policy for synchronous executions returning <typeparamref name="T<|fim_suffix|>/ <param name="context">The policy execution context.</param> /// <param name="cancellationToken">...
fim
App-vNext/Polly
csharp
<|fim_suffix|>t TResult Implementation<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken); } <|fim_prefix|>namespace Polly; public abstract partial class Policy { /// <summary> /// Defines the impl<|fim_middle|>ementation of a policy for sync execu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class Policy<TResult> : ISyncPolicy<TResult> { #region Execute overloads /// <summary> /// Executes the specified action within the policy and returns the Result. /// </summary> /// <param name="action">The action to perform.</param> /// ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>TResult}"/> indicating which exceptions and results the policy should handle.</param> protected Policy(PolicyBuilder<TResult>? policyBuilder = null) : base(policyBuilder) { } } <|fim_prefix|>#nullable enable namespace Polly; /// <summary> /// Transient fault handling policies that ca...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; /// <summary> /// Transient exception handling policies that can be applied to synchronous delegates. /// </summary> public abstract partial class Policy : PolicyBase { /// <summary> /// Initializes a new instance of the <see cref="Policy"/> class. /// </sum...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class PolicyBase { #pragma warning disable CA1051 // Do not declare visible instance fields #pragma warning disable IDE1006 /// <summary> /// A key intended to be unique to each <see cref="IsPolicy"/> instance. /// </summary> protected string poli...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Implements elements common to both non-generic and generic policies, and sync and async policies. /// </summary> public abstract partial class PolicyBase { /// <summary> /// Defines a value to use for continueOnCaptureContext, when none is supplied. /// </s...
fim
App-vNext/Polly
csharp
<|fim_suffix|> { var matchedInAggregate = HandleInnerNested(predicate, innerException); if (matchedInAggregate != null) { return matchedInAggregate; } } } return ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel; namespace Polly; /// <summary> /// Builder class that holds the list of current exception predicates. /// </summary> public sealed partial class PolicyBuilder { internal PolicyBuilder(ExceptionPredicate exceptionPredicate) { ExceptionPredicates = new Excepti...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// The captured result of executing a policy. /// </summary> public class PolicyResult { internal PolicyResult(OutcomeType outcome, Exception finalException, ExceptionType? exceptionType, Context context) { Outcome = outcome; FinalException = final...
fim
App-vNext/Polly
csharp
<|fim_suffix|>tException))] [assembly: TypeForwardedTo(typeof(CircuitState))] <|fim_prefix|>using System.Runtime.CompilerServices; using Polly; #pragma warning disable RS0016 [assembly: TypeForwardedTo(typeof(ExecutionRejectedException))] [assembly: TypeForwardedTo(typeof(TimeoutRejectedException))] [assembly: TypeFo...
fim
App-vNext/Polly
csharp
<|fim_suffix|> } throw new RateLimitRejectedException(retryAfter); } } <|fim_prefix|>#nullable enable namespace Polly.RateLimit; internal static class AsyncRateLimitEngine { internal static async Task<TResult> ImplementationAsync<TResult>( IRateLimiter rateLimiter, Func<TimeSpan, Con...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ext, continueOnCapturedContext, cancellationToken); } } <|fim_prefix|>#nullable enable namespace Polly.RateLimit; /// <summary> /// A rate-limit policy that can be applied to asynchronous delegates. /// </summary> public class AsyncRateLimitPolicy : AsyncPolicy, IRateLimitPol...
fim
App-vNext/Polly
csharp
<|fim_suffix|>f (numberOfExecutions < 1) { throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1."); } if (perTimeSpan <= TimeSpan.Zero) { th...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ngeException(nameof(maxBurst), maxBurst, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); if (onePer <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(name...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ing results of type <typeparamref name="TResult"/>. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> public interface IRateLimitPolicy<TResult> : IRateLimitPolicy { } <|fim_prefix|>#nullable enable namespace Polly.RateLimit; /// <summary> /// Defines properties and method...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly.RateLimit; /// <summary> /// Defines methods to be provided by a rate-limiter used in a Polly <see cref="IRateLimitPolicy"/>. /// </summary> internal interface IRateLimiter { /// <summary> /// Returns whether the execution is permitted; if not, returns what <see cref="TimeSpan...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.RateLimit; /// <summary> /// A lock-free token-bucket rate-limiter for a Polly <see cref="IRateLimitPolicy"/>. /// </summary> internal sealed class LockFreeTokenBucketRateLimiter : IRateLimiter { private readonly long _addTokenTickInterval; private readonly long ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Po<|fim_suffix|>{ internal static TResult Implementation<TResult>( IRateLimiter rateLimiter, Func<TimeSpan, Context, TResult>? retryAfterFactory, Func<Context, CancellationToken, TResult> action, Context context, CancellationToken can...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.RateLimit; /// <summary> /// A rate-limit policy that can be applied to synchronous delegates. /// </summary> public class RateLimitPolicy : Policy, IRateLimitPolicy { private readonly IRateLimiter _rateLimiter; internal RateLimitPolic<|fim_suffix|>/// <summary>...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable #if NETSTANDARD2_0 using System.Runtime.Serialization; #endif namespace Polly.RateLimit; #pragma warning disable RS0016 // Add public types and members to the declared API /// <summary> /// Exception thrown when a delegate executed through a <see cref="IRateLimitPolicy"/> is rate-lim...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; public partial class Policy { /// <summary> /// Builds a RateLimit <see cref="Policy"/> that will rate-limit executions to <paramref name="numberOfExecutions"/> per the timespan given. /// </summary> /// <param name="numberOfExecutions">The number of exe...
fim
App-vNext/Polly
csharp
<|fim_suffix|>, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); if (onePer <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, "The numb...
fim
App-vNext/Polly
csharp
namespace Polly.Registry; /// <summary> /// Represents a collection of policies keyed by <typeparamref name="TKey"/> which can be updated and consumed in a thread-safe manner. /// </summary> /// <typeparam name="TKey">The type of keys in the policy registry.</typeparam> public interface IConcurrentPolicyRegistry<TKey...
fim
App-vNext/Polly
csharp
<|fim_suffix|>TPolicy : IsPolicy; /// <summary> /// Gets or sets the <see cref="IsPolicy"/> with the specified key. /// <remarks>To retrieve a policy directly as a particular Policy type or Policy interface (avoiding a cast), use the <see cref="IReadOnlyPolicyRegistry{TKey}.Get{TPolicy}"/> method.</remarks...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Registry; /// <summary> /// Represents a read-only collection of policies keyed by <typeparamref name="TKey"/>. /// </summary> /// <typeparam name="TKey">The type of keys in the policy registry.</typeparam> public interface IReadOnlyPolicyRegistry<TKey> : IEnumerable<KeyValuePair<TKey, I...
fim
App-vNext/Polly
csharp
<|fim_suffix|>gistry"/>.</returns> /// <remarks> /// The enumerator returned from the registry is safe to use concurrently with /// reads and writes to the registry, however it does not represent a moment-in-time snapshot /// of the registry's contents. The contents exposed through the enumerator may c...
fim
App-vNext/Polly
csharp
using Polly.Utilities.Wrappers; namespace Polly; /// <summary> /// Extensions for conversion of resilience strategies to policies. /// </summary> public static class ResiliencePipelineConversionExtensions { /// <summary> /// Converts a <see cref="ResiliencePipeline"/> to an <see cref="IAsyncPolicy"/>. ///...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ramref name="result"/> matched the predicate; otherwise, false.</returns> public delegate bool ResultPredicate<in TResult>(TResult result);<|fim_prefix|>namespace Polly; /// <summary> /// A predicate that can be run agai<|fim_middle|>nst a passed result value of type <typeparamref name="TResult"/>. Pred...
fim
App-vNext/Polly
csharp
<|fim_suffix|>lass ResultPredicates<TResult> { private List<ResultPredicate<TResult>> _predicates; internal void Add(ResultPredicate<TResult> predicate) { _predicates ??= []; // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance be...
fim
App-vNext/Polly
csharp
<|fim_suffix|>unt, context).ConfigureAwait(continueOnCapturedContext); if (waitDuration > TimeSpan.Zero) { await SystemClock.SleepAsync(waitDuration, cancellationToken).ConfigureAwait(continueOnCapturedContext); } } } final...
fim
App-vNext/Polly
csharp
namespace Polly.Retry; /// <summary> /// A retry policy that can be applied to asynchronous delegates. /// </summary> public class AsyncRetryPolicy : AsyncPolicy, IRetryPolicy { private readonly Func<Exception, TimeSpan, int, Context, Task> _onRetryAsync; private readonly int _permittedRetryCount; private...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a <see cref="AsyncRetryPolicy" />. /// </summary> public static class AsyncRetrySyntax { /// <summary> /// Builds an <see cref="AsyncRetryPolicy"/> that will retry once. /// </summary> /// <param name="policyBuilder">The poli...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining an <see cref="AsyncRetryPolicy{TResult}" />. /// </summary> public static class AsyncRetryTResultSyntax { /// <summary> /// Builds an <see cref="AsyncRetryPolicy{TResult}"/> that will retry once. /// </summary> /// <typeparam...
fim
App-vNext/Polly
csharp
<|fim_suffix|>lic interface IRetryPolicy<TResult> : IRetryPolicy { } <|fim_prefix|>namespace Polly.Retry; /// <summary> /// Defines properties and methods common to all Retry policies. /// </s<|fim_middle|>ummary> public interface IRetryPolicy : IsPolicy { } /// <summary> /// Defines properties and methods common to...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Retry; internal static class RetryEngine { [DebuggerDisableUserUnhandledExceptions] internal static TResult Implementation<TResult>( Func<Context, CancellationToken, TResult> action, Context context, ExceptionPredicates shouldRetryExceptio...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Retry; /// <<|fim_suffix|> _sleepDurationProvider); } } <|fim_middle|>summary> /// A retry policy that can be applied to synchronous delegates. /// </summary> public class RetryPolicy : Policy, IRetryPolicy { private readonly Action<Exception, TimeSpan, int, Con...
fim
App-vNext/Polly
csharp
<|fim_suffix|>cyBuilder, onRetry, sleepDurationsEnumerable: sleepDurations); } /// <summary> /// Builds a <see cref="Policy"/> that will wait and retry indefinitely until the action succeeds. /// On each retry, the duration to wait is calculated by calling <paramref name="sl...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ng the duration to wait before retrying.</param> /// <param name="onRetry">The action to call on each retry.</param> /// <returns>The policy instance.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="sleepDurationProvider"/> is <see langword="null"/>.</exceptio...
fim
App-vNext/Polly
csharp
namespace Polly.Timeout; internal static class AsyncTimeoutEngine { [DebuggerDisableUserUnhandledExceptions] internal static async Task<TResult> ImplementationAsync<TResult>( Func<Context, CancellationToken, Task<TResult>> action, Context context, Func<Context, TimeSpan> timeoutProvide...
fim
App-vNext/Polly
csharp
<|fim_suffix|>executed through the policy.</typeparam> public class AsyncTimeoutPolicy<TResult> : AsyncPolicy<TResult>, ITimeoutPolicy<TResult> { private readonly TimeoutStrategy _timeoutStrategy; private readonly Func<Context, TimeSpan> _timeoutProvider; private readonly Func<Context, TimeSpan, Task, Excep...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public partial class Policy { /// <summary> /// Builds an <see cref="AsyncPolicy"/> that will wait asynchronously for a delegate to complete for a specified period of time. A <see cref="TimeoutRejectedException"/> will be thrown if the delegate does not complete within the confi...
fim
App-vNext/Polly
csharp
<|fim_suffix|><typeparam name="TResult">The type of the result.</typeparam> /// <param name="timeoutProvider">A function to provide the timeout for this execution.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="timeoutProvider"/> is <see langword="null"/>.</exception> /// <r...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Timeout; /// <summary> /// Defines properties and methods common to all Timeout policies. /// </summary><|fim_suffix|>licy<TResult> : ITimeoutPolicy { } <|fim_middle|> public interface ITimeoutPolicy : IsPolicy { } /// <summary> /// Defines properties and methods common to all Timeout p...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ception ex) { // Note that we cannot rely on testing (operationCanceledException.CancellationToken == combinedToken || operationCanceledException.CancellationToken == timeoutCancellationTokenSource.Token) // as either of those tokens could have been onward combined with ano...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Timeout; /// <summary> /// A timeout policy which can be applied to delegates. /// </summary> public class TimeoutPolicy : Policy, ITimeoutPolicy { private readonly TimeoutStrategy _timeoutStrategy; private readonly Func<Context, TimeSpan> _timeoutProvider; private readonly A...
fim
App-vNext/Polly
csharp
<|fim_suffix|> any timing-out <see cref="CancellationToken"/> but the policy will still guarantee timing out (and returning to the caller) by other means. /// </summary> Pessimistic } <|fim_prefix|>namespace Polly.Timeout; /// <summary> /// Defines how timeouts are enforced. /// </summary> public enum TimeoutS...
fim
App-vNext/Polly
csharp
<|fim_suffix|>if (timeoutProvider == null) { throw new ArgumentNullException(nameof(timeoutProvider)); } return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeout); } /// <summary> /// Builds a <see cref="Policy" /> that will wait for a delegate to co...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ction to call on timeout, passing the execution context, the timeout applied, the <see cref="Task{TResult}" /> capturing the abandoned, timed-out action, and the captured <see cref="Exception"/>. /// <remarks>The Task parameter will be null if the executed action responded cooperatively to cancellatio...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Timeout; internal static class TimeoutValidator { internal static void ValidateSecondsTimeout(int seconds) { if (seconds <= 0) { th<|fim_suffix|>pan to indicate no timeout)"); } } } <|fim_middle|>row new ArgumentOutOfRangeException(nameof(s...
fim
App-vNext/Polly
csharp
<|fim_suffix|>static readonly EmptyStruct Instance; } <|fim_prefix|>namespace Polly.Utilities; /// <summary> /// A null struct for policies and actions which do not return a TResult. /// </summary> internal readonly stru<|fim_middle|>ct EmptyStruct { internal <|endoftext|>
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable using System.Runtime.ExceptionServices; namespace Polly.Utilities; /// <summary> /// Contains extension methods on the <see cref="Except<|fim_suffix|>rom <paramref name="exceptionToCompare"/>.</param> /// <param name="exceptionToCompare">The exception to compare against.</param> ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ToString().Substring(0, GuidPartLength); #endif } <|fim_prefix|>#nullable enable namespace Polly.Utilities; internal static class KeyHelper { private const int GuidPartLength = 8; public static string GuidPart(<|fim_middle|>) => #if NET6_0_OR_GREATER Guid.NewGuid().ToString()[..GuidPart...
fim
App-vNext/Polly
csharp
<|fim_suffix|> } }; SleepAsync = Task.Delay; UtcNow = () => DateTime.UtcNow; DateTimeOffsetUtcNow = () => DateTimeOffset.UtcNow; CancelTokenAfter = (tokenSource, timespan) => tokenSource.CancelAfter(timespan); } } <|fim_prefix|>#nullable enable namespace Polly.Utilities;...
fim
App-vNext/Polly
csharp
<|fim_suffix|>/ Non-constant fields should not be visible #pragma warning disable S2223 // Non-constant static fields should not be visible /// <summary> /// Defines a completed Task for use as a completed, empty asynchronous delegate. /// </summary> public static Task EmptyTask = Task.CompletedTask; #p...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Utilities; // Adapted from the link below, with slight modifications. // https://www.interact-sw.co.uk/iangblog/2004/04/26/yetmoretimedlocking // Ian Griffiths (original TimedLock author) wrote: // Thanks to Eric Gunnerson for recommending this be a struct rather // tha...
fim
App-vNext/Polly
csharp
<|fim_suffix|> ResilienceContextPool.Shared.Return(resilienceContext); } } <|fim_prefix|>namespace Polly.Utilities.Wrappers; internal static class ResilienceContextFactory { public static ResilienceContext Create( Context context, bool continueOnCapturedContext, out IDictionary<stri...
fim
App-vNext/Polly
csharp
<|fim_suffix|>static async (resilienceContext, state) => { return await state.action(state.context, resilienceContext.CancellationToken).ConfigureAwait(resilienceContext.ContinueOnCapturedContext); }, resilienceContext, (action, context...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ecuteAsync( static async (resilienceContext, state) => { return await state.action(state.context, resilienceContext.CancellationToken).ConfigureAwait(resilienceContext.ContinueOnCapturedContext); }, resilienceContext, ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Utilities.Wrappers; internal sealed class ResiliencePipelineSyncPolicy<TResult> : Policy<TResult> { private readonly ResiliencePipeline<TResult> _pipeline; public ResiliencePipelineSyncPolicy(ResiliencePipeline<TResult> strategy) => _pipeline = strategy; protected override T...
fim
App-vNext/Polly
csharp
<|fim_suffix|>n) { var resilienceContext = ResilienceContextFactory.Create( context, true, out var oldProperties, cancellationToken); try { return _pipeline.Execute( static (context, state) => { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>t from the executing <see cref="PolicyWrap{TResult}"/>. /// </summary> /// <param name="executionContext">The execution <see cref="Context"/>.</param> /// <param name="priorPolicyWrapKey">The <see cref="Context.PolicyWrapKey"/> prior to changes by this method.</param> /// <param name="prio...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Wrap; /// <summary> /// A policy that allows two (and by recursion more) async Polly policies to wrap executions of async delegates. /// </summary> public partial class AsyncPolicyWrap : AsyncPolicy, IPolicyWrap { private readonly IAsyncPolicy _outer; private readonly IAsyncPolic...
fim
App-vNext/Polly
csharp
<|fim_suffix|>) => innerPolicy.ExecuteAsync( func, ctx, ct, continueOnCapturedContext), context, cancellationToken, continueOnCapturedContext); internal static Task<TResult> ImplementationAsync<TResult>( Fun...
fim
App-vNext/Polly
csharp
<|fim_suffix|>], policies[1]), _ => WrapAsync(policies[0], WrapAsync([.. policies.Skip(1)])), }; #pragma warning restore S3215 // "interface" instances should not be cast to concrete types } /// <summary> /// Creates a <see cref="PolicyWrap" /> of the given policies governing delegates ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>param> public interface IPolicyWrap<TResult> : IPolicyWrap { } <|fim_prefix|>namespace Polly.Wrap; /// <summary> /// Defines properties and methods common to all PolicyWrap policies. /// </summary> public interface IPolicyWrap : IsPolicy { /// <summary> /// Gets the outer <see cref="IsPolicy"/> ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>icy; } } } } <|fim_prefix|>namespace Polly.Wrap; /// <summary> /// Extension methods for IPolicyWrap. /// </summary> public static class IPolicyWrapExtension { /// <summary> /// Returns all the policies in this <see cref="IPolicyWrap"/>, in Outer-to-Inner order. /// <...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Defines extensions for configuring <see cref="PolicyWrap"/> instances on an <see cref="ISyncPolicy"/> or <see cref="ISyncPolicy{TResult}"/>. /// </summary> public static class ISyncPolicyPolicyWrapExtensions { /// <summary> /// Wraps the specified outer policy ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.Wrap; public partial class PolicyWrap { /// <summary> /// Updates the execution <see cref="Context"/> with context from the executing <see cref="PolicyWrap"/>. /// </summary> /// <param name="executionContext">The execution <see cref="Context"/>.</param> /// <param na...
fim
App-vNext/Polly
csharp
<|fim_suffix|>er) : base(outer.ExceptionPredicates, ResultPredicates<TResult>.None) { _outerNonGeneric = outer; _innerGeneric = inner; } internal PolicyWrap(Policy<TResult> outer, ISyncPolicy inner) : base(outer.ExceptionPredicates, outer.ResultPredicates) { _out...
fim
App-vNext/Polly
csharp
<|fim_suffix|>entation<TResult>( Func<Context, CancellationToken, TResult> func, Context context, ISyncPolicy<TResult> outerPolicy, ISyncPolicy innerPolicy, CancellationToken cancellationToken) => outerPolicy.Execute((ctx, ct) => innerPolicy.Execute(func, ctx, ct), contex...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.ComponentModel; namespace Polly.CircuitBreaker; #pragma warning disable CA1815 // Override equals and operator equals on value types /// <summary> /// Represents arguments used to generate a dynamic break duration for a circuit breaker. /// </summary> public readonly struct BreakDurationGe...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Context" /> that contains contextual information about the source or destination.</param> protected BrokenCircuitException(SerializationInfo info, StreamingContext context) : base(info, context) { Guard.NotNull(info); // https://github.com/dotnet/runtime/issues/42460 ...
fim
App-vNext/Polly
csharp
namespace Polly.CircuitBreaker; internal static class CircuitBreakerConstants { public const string DefaultName = "CircuitBreaker"; public const string OnCircuitClosed = "OnCircuitClosed"; public const string OnHalfOpenEvent = "OnCircuitHalfOpened"; public const string OnCircuitOpened = "OnCircuitOp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// Allows manual control of the circuit-breaker. /// </summary> /// <remarks> /// The instance of this class can be reused across multiple circuit breakers. /// </remarks> public sealed class CircuitBreakerManualControl { private readonly object _lock = ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; #pragma warning disab<|fim_suffix|>> /// <remarks> /// Always use the constructor when creating this struct, otherwise we do not guarantee binary compatibility. /// </remarks> public readonly struct CircuitBreakerPredicateArguments<TResult> : IOutcomeArguments<TResult> { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|> /// <returns>A builder with the circuit breaker added.</returns> /// <remarks> /// See <see cref="CircuitBreakerStrategyOptions{TResult}"/> for more details about the circuit breaker. /// <para> /// If you are discarding the circuit breaker by this call make sure to use <see cref="Circ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ning disable CA1031 catch (Exception ex) { outcome = new(ex); } #pragma warning restore CA1031 var args = new CircuitBreakerPredicateArguments<T>(context, outcome); if (await _handler(args).ConfigureAwait(context.ContinueOnCapturedContext)) { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ets the state of the underlying circuit. /// </summary> public CircuitState CircuitState => _circuitStateProvider?.Invoke() ?? CircuitState.Closed; } <|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// Allows retrieval of the circuit breaker state. /// </summary> public sealed clas<|f...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; namespace Polly.CircuitBreaker; /// <summary> /// The options for circuit breaker resilience strategy. /// </summary> /// <typeparam name="TResult">The type of result the circuit breaker strategy handles.</...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespac<|fim_suffix|> public class CircuitBreakerStrategyOptions : CircuitBreakerStrategyOptions<object> { } <|fim_middle|>e Polly.CircuitBreaker; /// <inheritdoc/><|endoftext|>
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// Describes the possible states the circuit of a Circuit Breaker may be in. /// </summary> public enum CircuitState { /// <summary> /// Closed - When the circuit is closed. Execution of actions is allowed. /// </summary> Closed, /// <su...
fim
App-vNext/Polly
csharp
<|fim_suffix|> case CircuitState.Open: case CircuitState.Isolated: // A failure call result may arrive when the circuit is open, if it was placed before the circuit broke. // We take no action beyond tracking the metric // We do not want to duplicate-...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace<|fim_suffix|><summary> /// Defines the behavior of circuit breaker. All methods on this class are performed under a lock. /// </summary> internal abstract class CircuitBehavior { public abstract void OnActionSuccess(CircuitState currentState); public abstract void OnActionFailure(Circui...
fim
App-vNext/Polly
csharp
<|fim_suffix|>silienceContext context) { EnsureNotDisposed(); var task = Task.CompletedTask; lock (_lock) { SetLastHandledOutcome_NeedsLock(outcome); _behavior.OnActionFailure(_circuitState, out var shouldBreak); // Circuit state handling ...
fim
App-vNext/Polly
csharp
namespace Polly.CircuitBreaker; #pragma warning disable CA1031 // Do not catch general exception types /// <summary> /// The scheduled task executor makes sure that tasks are executed in the order they were scheduled and not concurrently. /// </summary> internal sealed class ScheduledTaskExecutor : IDisposable { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>tal == 0) { return new HealthInfo(0, 0, failures); } return new(total, failures / (double)total, failures); } } <|fim_prefix|>namespace Polly.CircuitBreaker.Health; internal readonly record struct HealthInfo(int Throughput, double FailureRate, int Failu<|fim_middl...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker.Health; /// <summary> /// The health metrics for advanced circuit breaker. /// All operations here are executed from <see cref="CircuitStateController{T}"/> under a lock and are thread safe. /// </summary> internal abstract class HealthMetrics { private const short Numb...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Window.StartedAt >= _windowDuration) { _currentWindow = new() { StartedAt = now }; _windows.Enqueue(_currentWindow); } while (now - _windows.Peek().StartedAt >= _samplingDuration) { _windows.Dequeu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker.Health; /// <inheritdoc/> internal sealed class SingleHealthMetrics : Hea<|fim_suffix|>o() { TryReset(); return HealthInfo.Create(_successes, _failures); } private void TryReset() { if (TimeProvider.GetUtcNow() - _startedAt >= _samp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#if !NETCOREAPP using System.Runtime.Serialization; #endif namespace Polly.CircuitBreaker; /// <summary> /// Exception thrown when a circuit is isolated (held open) by manual override. /// </summary> #if !NETCOREAPP [Serializable] #endif public class IsolatedCircuitException : BrokenCircuitException { ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; #pragma warning disable CA1815 // Override equals and operator equals on value types /// <summary> /// Arguments used by <see cref="CircuitBreakerStrategyOptions{TResult}.<|fim_suffix|>atibility. /// </remarks> public readonly struct OnCircuitClosedArguments<TResult> : IO...
fim
App-vNext/Polly
csharp
<|fim_suffix|>d callback. /// </summary> public ResilienceContext Context { get; } } <|fim_prefix|>namespace Polly.CircuitBreaker; #pragma warning disable CA1815 // Override equals and operator equals on value types /// <summary> /// Arguments used by <see cref="CircuitBreakerStrategyOptions{TResult}.OnHalfOp...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; #pragma warning disable CA1815 // Override equals and operator equals on value types /// <summary> /// Arguments used by <see cref="CircuitBreakerStrategyOptions{TResult}.On<|fim_suffix|>ummary> /// Gets the duration of break. /// </summary> public TimeSpan Br...
fim
App-vNext/Polly
csharp