text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|> /// </summary> NonPublicFields = 0x0040, /// <summary> /// Specifies all public nested types. /// </summary> PublicNestedTypes = 0x0080, /// <summary> /// Specifies all non-public nested types. /// </summary> NonPublicNestedTypes = 0x0100, /// <summary> /// ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #pragma warning disable IDE0079 #pragma warning disable SA1101 #pragma warning disable SA1116 #pragma warning disable SA1117 <|fim_suffix|>type <see cref="string"/>, th...
fim
App-vNext/Polly
csharp
<|fim_prefix|>// Copyright (c) Microsoft Corporation. All Rights Reserved. #pragma warning disable IDE<|fim_suffix|>/ namespace System.Runtime.CompilerServices; internal static class IsExternalInit { } <|fim_middle|>0079 #pragma warning disable S3903 /* This enables support for C# 9/10 records on older frameworks *...
fim
App-vNext/Polly
csharp
<|fim_prefix|>// Copyright (c) Microsoft Corporation. All Rights Reserved. #pragma warning disable IDE0079 #pragma warning disable IDE0079 #pragma warning disable SA1101 #pragma warning disable SA1116 #pragma warning disable SA1117 #pragma warning disable SA1402 #pragma warning disable SA1512 #pragma warning disable S...
fim
App-vNext/Polly
csharp
<|fim_suffix|>age of unreferenced code. /// </summary> public string Message { get; } /// <summary> /// Gets or sets an optional URL that contains more information about the method, /// why it requires unreferenced code, and what options a consumer has to deal with it. /// </summary> public...
fim
App-vNext/Polly
csharp
<|fim_prefix|>// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #pragma warning disable IDE0079 #pragma warning disable SA1101 #pragma warning disable SA1116 #pragma warning disable SA1117 #pragma warning disable SA1512 #pragma warn...
fim
App-vNext/Polly
csharp
<|fim_suffix|> { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); } policyKeyInternal = policyKey; return this; } } public abstract partial class AsyncPolicy<TResult> { /// <summary> /// Sets the PolicyKey for this <see cref="AsyncPolicy{TResult}"/> ins...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class AsyncPolicy : PolicyBase, IAsyncPolicy { #region ExecuteAsync overloads /// <summary> /// Executes the specified asynchronous action within the policy. /// </summary> /// <param name="action">The action to perform.</param> /// <...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; public abstract partial class AsyncPolicy<TResult> { #pragma warning disable CA1068 /// <summary> /// Defines the implem<|fim_suffix|>should be cancelled.</param> /// <param name="continueOnCapturedContext">Whether async continuations should continue on a captured context.</...
fim
App-vNext/Polly
csharp
<|fim_suffix|>m name="action">The action passed by calling code to execute through the policy.</param> /// <param name="context">The policy execution context.</param> /// <param name="cancellationToken">A token to signal that execution should be cancelled.</param> /// <param name="continueOnCapturedContext"...
fim
App-vNext/Polly
csharp
<|fim_suffix|>exception), context); } } } <|fim_prefix|>namespace Polly; public abstract partial class AsyncPolicy<TResult> : IAsyncPolicy<TResult> { #region ExecuteAsync overloads /// <summary> /// Executes the specified asynchronous action within the policy and returns the result. /...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; /// <summary> /// Transient exception handling policies that can be applied to asynchronous delegates. /// </summary> /// <typeparam name="TResult">The return type of delegates whic<|fim_suffix|>cy( ExceptionPredicates exceptionPredicates, ResultPredicat...
fim
App-vNext/Polly
csharp
<|fim_suffix|>(PolicyBuilder? policyBuilder = null) : base(policyBuilder) { } } <|fim_prefix|>#nullable enable namespace Polly; /// <summary> /// Transient exception handling policies that can be applied to asynchronous delegates. /// </summary> public abstract partial class AsyncPolicy { /// <sum...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Bulkhead; internal static class AsyncBulkheadEngine { internal static async Task<TResult> ImplementationAsync<TResult>( Func<Context, CancellationToken, Task<TResult>> action, Context context, Func<Context, Task> onBulkheadRejectedAsync<|fim_s...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Bulkhead; /// <summary> /// A bulkhead-isolation policy which can be applied to delegates. /// </summary> #pragma warning disable CA1063 public class AsyncBulkheadPolicy : AsyncPolicy, IBulkheadPolicy #pragma warning restore CA1063 { private readonly SemaphoreSlim _m...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; #pragma warning disable CA1724 public partial class Policy #pragma warning restore CA1724 { /// <summary> /// <para>Builds a bulkhead isolation <see cref="Policy"/>, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ncPolicy{TResult}" />, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// <para>When an execution would cause the number of actions executing concurrently th...
fim
App-vNext/Polly
csharp
<|fim_suffix|>horeSlim semaphore) { try { semaphore.Release(); } catch (ObjectDisposedException) { // Ignore - this can happen if the caller disposed the semaphore } } } } <|fim_prefix|>#nullable...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Bulkhead; /// <summary> /// A bulkhead-isolation policy which can be applied to delegates. /// </summary> #pragma warning disable CA1063 public class BulkheadPolicy : Policy, IBulkheadPolicy #pragma warning restore CA1063 { private readonly SemaphoreSlim _maxParallel...
fim
App-vNext/Polly
csharp
<|fim_suffix|> API } <|fim_prefix|>#nullable enable #if NETSTANDARD2_0 using System.Runtime.Serialization; #endif namespace Polly.Bulkhead; /// <summary> /// Exception thrown when a bulkhead's semaphore and queue are full. /// </summary> #if NETSTANDARD2_0 [Serializable] #endif public class BulkheadRejectedException...
fim
App-vNext/Polly
csharp
<|fim_suffix|>edActionsSemaphore); } } <|fim_prefix|>#nullable enable namespace Polly.Bulkhead; internal static class BulkheadSemaphoreFactory { public static (SemaphoreSlim MaxParallelizationSemaphore, SemaphoreSlim MaxQueuedActionsSemaphore) CreateBulkheadSemaphores(int maxParallelization, int maxQueueingAc...
fim
App-vNext/Polly
csharp
<|fim_suffix|>through the policy to exceed <paramref name="maxParallelization"/>, the action is not executed and a <see cref="BulkheadRejectedException"/> is thrown.</para> /// </summary> /// <param name="maxParallelization">The maximum number of concurrent actions that may be executing through the policy.</par...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; public partial class Policy { /// <summary> /// <para>Builds a bulkhead isolation <see cref="Policy{TResult}"/>, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Bulkhead; /// <summary> /// Defines properties and methods common to all bulkhead policies. /// </summary> public interface IBulkheadPolicy : IsPolicy, IDisposable { /// <summary> /// Gets the number of slots currently available for executing actions through the ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <su<|fim_suffix|>s AbsoluteTtl : NonSlidingTtl { /// <summary> /// Initializes a new instance of the <see cref="AbsoluteTtl"/> class. /// </summary> /// <param name="absoluteExpirationTime">The UTC point in time until which to consider the ca...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; internal static class AsyncCacheEngine { [DebuggerDisableUserUnhandledExceptions] internal static async Task<TResult> ImplementationAsync<TResult>( IAsyncCacheProvider<TResult> cacheProvider, ITtlStrategy<TResult> ttlStrategy, Fun...
fim
App-vNext/Polly
csharp
<|fim_suffix|>[DebuggerStepThrough] protected override Task<TResult> ImplementationAsync( Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (action is null) { ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>Delegate to call on cache put.</param> /// <param name="onCacheGetError">Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.</param> /// <param name="onCachePutError">Delegate to call if an excep...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly; public partial class Policy { /// <summary> /// <para>Builds an <see cref="AsyncPolicy{TResult}"/> that will function like a result cache for delegate executions returning a <typeparamref name="TResult"/>.</para> /// <para>Before executing a delegate, checks whether the <...
fim
App-vNext/Polly
csharp
<|fim_suffix|>heProvider<TCacheFormat>.TryGetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext) { (bool cacheHit, object? cached) = await _wrappedCacheProvider.TryGetAsync(key, cancellationToken, continueOnCapturedContext).ConfigureAwait(continueOnCapturedContext); ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>/typeparam> public class AsyncSerializingCacheProvider<TResult, TSerialized> : IAsyncCacheProvider<TResult> { private readonly IAsyncCacheProvider<TSerialized> _wrappedCacheProvider; private readonly ICacheItemSerializer<TResult, TSerialized> _serializer; /// <summary> /// Initializes a n...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ovider.Put(cacheKey, result, ttl); onCachePut(context, cacheKey); } #pragma warning disable CA1031 catch (Exception ex) #pragma warning restore CA1031 { onCachePutError?.Invoke(context, cacheKey, ex); } } retu...
fim
App-vNext/Polly
csharp
<|fim_suffix|>y<TResult> { private readonly Action<Context, string> _onCacheGet; private readonly Action<Context, string> _onCacheMiss; private readonly Action<Context, string> _onCachePut; private readonly Action<Context, string, Exception>? _onCacheGetError; private readonly Action<Context, string...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Class that provides helper methods for configuring CacheProviders. /// </summary> public static class CacheProviderExtensions { /// <summary> /// Provides a strongly <typeparamref name="TCacheFormat"/>-typed version of the supplied <see...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly; public partial class Policy { /// <summary> /// <para>Builds a <see cref="Policy"/> that will function like a result cache for delegate executions returning a result.</para> /// <para>Before executing a delegate returning a result, checks whether the <paramref name="cache...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; public partial class Policy { /// <summary> /// <para>Builds a <see cref="Policy{TResult}"/> that will function like a result cache for delegate executions returning a <typeparamref name="TResult"/>.</para> /// <para>Before executing a delegate, checks wheth...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines a ttl strategy which will cache items for a TimeSpan which may be influenced by data in the execution context. /// </summary> public class ContextualTtl : ITtlStrategy { /// <summary> /// The key on the execution <see cref="Cont...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// The default cache key strategy for <see cref="CachePolicy"/>. Returns the property <see cref="Context.OperationKey"/>. /// </summary> public class DefaultCacheKeyStrategy : ICacheKeyStrategy { /// <summary> /// Gets the cache key from ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>? result = default; if (cacheHit) { result = (TCacheFormat?)cached; } return (cacheHit, result); } void ISyncCacheProvider<TCacheFormat>.Put(string key, TCacheFormat? value, Ttl ttl) => _wrappedCacheProvider.Put(key, value, ttl); } <|fim_prefi...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly.Caching; /// <summary> /// Represents a strongly-typed <see cref="ITtlStrategy"/> wrapper of a non-generic strategy. /// </summary> internal sealed class GenericTtlStrategy<TResult> : ITtlStrategy<TResult> { private readonly ITtlStrategy _wrappedTtlStrategy; internal GenericT...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines methods<|fim_suffix|>nue on a captured synchronization context. <para><remarks>Note: if the underlying cache's async API does not support controlling whether to continue on a captured context, async Policy executions with continueOnCapt...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines operations for serializing and deseri<|fim_suffix|>ary> /// Serializes the specified object. /// </summary> /// <param name="objectToSerialize">The object to serialize.</param> /// <returns>The serialized object.</return...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Cach<|fim_suffix|>); } <|fim_middle|>ing; /// <summary> /// Defines how a <see cref="CachePolicy"/> should get a string cache key from an execution <see cref="Context"/>. /// </summary> public interface ICacheKeyStrategy { /// <summary> /// Gets the cache key fro...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines properties and methods common to all Cache policies. /// </summary> public interface ICachePolicy : IsPolicy { } /// <summary> /// Defines properties and methods common<|fim_suffix|>ref name="TResult"/>. /// </summary> /// <typeparam n...
fim
App-vNext/Polly
csharp
<|fim_suffix|>> /// <param name="value">The value to put into the cache.</param> /// <param name="ttl">The time-to-live for the cache entry.</param> void Put(string key, object? value, Ttl ttl); } /// <summary> /// Defines methods for classes providing synchronous cache functionality for Polly <see cref="C...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines a strategy for providing time-to-live durations for cacheable results. /// </summary> public interface ITtlStrategy : ITtlS<|fim_suffix|>.</returns> Ttl GetTtl(Context context, TResult? result); } <|fim_middle|>trategy<object> { } ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Represents an <see cref="ITtlStrategy"/> expiring at an absolute time, not with sliding expiration. /// </summary> public abstract class NonSlidingTtl : ITtlStrategy { #pragma warning disable CA1051 // Do not declare visible instance fields #pr...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly.Caching; /// <summary> /// Defines a ttl strategy which will cache items for the specified time. /// </summary> public class RelativeTtl : ITtlStrategy { private readonly TimeSpan _ttl; /// <summary> /// Initializes a new instance of the <see cref="RelativeTtl"/> class. ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines a ttl strategy which can calculate a duration to cache items dynamically based on the execution context and result of the execution. /// </summary> /// <typeparam name="TResult">The type of results that the ttl calculation function will...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines an <see cref="ISyncCacheProvider"/> which serializes objects of any type in and out of an underlying cache which caches as type <typeparamref name="TSerialized"/>. For use with synchronous <see cref="CachePolicy" />. /// </summary> ///...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Defines a ttl strategy which will cache items with a sliding ttl. /// </summary> public class SlidingTtl : ITtlStrategy { private readonly Ttl _ttl; /// <summary> /// Initializes a new instance of the <see cref="SlidingTtl"/> class...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly.Caching; /// <summary> /// Represents a time-to-live for a given cache item. /// </summary> #pragma warning disable CA1815 //Override equals and operator equals on value types public struct Ttl #pragma warning restore CA1815 { #pragma warning disable CA1051 // Do not declare visible i...
fim
App-vNext/Polly
csharp
<|fim_suffix|> new GenericTtlStrategy<TResult>(ttlStrategy); } <|fim_prefix|>#nullable enable namespace Polly.Caching; /// <summary> /// Class that provides helper methods for configuring TtlStrategies. /// </summary> internal static class TtlStrategyExtensions { /// <summary> /// Provides a strongly <typep...
fim
App-vNext/Polly
csharp
<|fim_suffix|>he failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure.</param> /// <param name="samplingDuration">The duration of the timeslice over which failure ratios are assessed.</param> /// <param name...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="Policy{TResult}"/>. /// </summary> public static class AdvancedCircuitBreakerTResultSyntax { /// <summary> /// <para> Builds a <see cref="Policy{TResult}"/> that will function like a Circuit Breaker.</para> ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; internal sealed class AdvancedCircuitController<TResult> : CircuitStateController<TResult> { internal static readonly long ResolutionOfCircuitTimer = TimeSpan.FromMilliseconds(20).Ticks; #pragma warning disable IDE0032 // Use auto property private readonly IHealt...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="AsyncPolicy"/>. /// </summary> public static class AsyncAdvancedCircuitBreakerSyntax { /// <summary> /// <para> Builds a <see cref="AsyncPolicy"/> that will function like a Circuit Breaker.</para> /// <pa...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="Asyn<|fim_suffix|>yBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Actio...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; inter<|fim_suffix|> throw; } } } <|fim_middle|>nal static class AsyncCircuitBreakerEngine { [DebuggerDisableUserUnhandledExceptions] internal static async Task<TResult> ImplementationAsync<TResult>( Func<Context, CancellationToken, Task<T...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// A circuit-breaker policy that can be applied to async delegates. /// </summary> public class AsyncCircuitBreakerPolicy : AsyncPolicy, ICircuitBreakerPolicy { internal readonly ICircuitController<EmptyStruct> BreakerController; internal AsyncCirc...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="AsyncPolicy"/>. /// </summary> public static class AsyncCircuitBreakerSyntax { /// <summary> /// <para> Builds a <see cref="AsyncPolicy"/> that will function like a Circuit Breaker.</para> /// <para>The c...
fim
App-vNext/Polly
csharp
<|fim_suffix|>ill break /// again for another <paramref name="durationOfBreak"/>; if no exception or handled result is encountered, the circuit will reset. /// </para> /// </summary> /// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam> /// ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#if !NETCOREAPP using System.Runtime.Serialization; #endif namespace Polly.CircuitBreaker; #pragma warning disable CA1032 // Implement standard exception constructors /// <summary> /// Exception thrown when a circuit is broken. /// </summary> /// <typeparam name="TResult">The type of returned results b...
fim
App-vNext/Polly
csharp
<|fim_prefix|>using System.Runtime.ExceptionServices; namespace Polly.CircuitBreaker; internal static class CircuitBreakerEngine { [DebuggerDisableUserUnhandledExceptions] internal static TResult Implementation<TResult>( Func<Context, CancellationToken, TResult> action, Context context, ...
fim
App-vNext/Polly
csharp
namespace Polly.CircuitBreaker; /// <summary> /// A circuit-breaker policy that can be applied to delegates. /// </summary> public class CircuitBreakerPolicy : Policy, ICircuitBreakerPolicy { internal readonly ICircuitController<EmptyStruct> BreakerController; internal CircuitBreakerPolicy( PolicyBui...
fim
App-vNext/Polly
csharp
namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="Policy"/>. /// </summary> public static class CircuitBreakerSyntax { /// <summary> /// <para> Builds a <see cref="Policy"/> that will function like a Circuit Breaker.</para> /// <para>The circuit will break if <paramref...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Fluent API for defining a Circuit Breaker <see cref="Policy{TResult}"/>. /// </summary> public static class CircuitBreakerTResultSyntax { /// <summary> /// <para> Builds a <see cref="Policy{TResult}"/> that will function like a Circuit Breaker.</para> /// <...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; internal abstract class CircuitStateController<TResult> : ICircuitController<TResult> { protected readonly TimeSpan DurationOfBreak; protected readonly Action<DelegateResult<TResult>, CircuitState, TimeSpan, Context> OnBreak; protected readonly Action<Context>...
fim
App-vNext/Polly
csharp
<|fim_suffix|> time for which the circuit is broken. We do not want to mask the fact that the call executed (as replacing its result with a Broken/IsolatedCircuitException would do). default: throw new InvalidOperationException("Unhandled CircuitState."); } } } <|fim_prefix|>n...
fim
App-vNext/Polly
csharp
<|fim_suffix|>uccesses + Failures; public long StartedAt { get; set; } } <|fim_prefix|>namespace Polly.CircuitBre<|fim_middle|>aker; internal sealed class HealthCount { public int Successes { get; set; } public int Failures { get; set; } public int Total => S<|endoftext|>
fim
App-vNext/Polly
csharp
namespace Polly.CircuitBreaker; /// <summary> /// Defines properties and methods common to all circuit-breaker policies. /// </summary> public interface ICircuitBreakerPolicy : IsPolicy { /// <summary> /// Gets the state of the underlying circuit. /// </summary> CircuitState CircuitState { get; } ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// Interface for controlling a circuit breaker. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> internal interface ICircuitController<TResult> { /// <summary> /// Gets the state of the circuit. /// </summary> ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>> void Reset_NeedsLock(); /// <summary> /// Gets the health count. /// </summary> /// <returns>The current health count.</returns> HealthCount GetHealthCount_NeedsLock(); } <|fim_prefix|>namespace Polly.CircuitBreaker; /// <summary> /// Interface for managing health metrics. ///...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.CircuitBreaker; internal sealed class RollingHealthMetrics : IHealthMetrics { internal const short WindowCount = 10; private readonly long _samplingDuration; private readonly long _windowDuration; private readonly Queue<HealthCount> _windows; privat...
fim
App-vNext/Polly
csharp
<|fim_suffix|>HealthCount? _current; public SingleHealthMetrics(TimeSpan samplingDuration) => _samplingDuration = samplingDuration.Ticks; public void IncrementSuccess_NeedsLock() => ActualiseCurrentMetric_NeedsLock().Successes++; public void IncrementFailure_NeedsLock() => Actuali...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; #pragma warning disable CA1033,S4039 // Interface methods should be callable by child types /// <summary> /// Context that carries with a single execution through a Policy. Commonly-used properties are directly on the class. Backed by a dictionary of string key / object value pairs,...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Context that carries with a single execution through a Policy. Commonly-used properties are directly on the class. Backed by a dictionary of string key / object value pairs, to which user-defined values may be added. /// <remarks>Do not re-use an instance of <see cre...
fim
App-vNext/Polly
csharp
<|fim_suffix|> public DelegateResult(Exception exception) => Exception = exception; /// <summary> /// Gets the result of executing the delegate. Will be default(TResult) if an exception was thrown. /// </summary> public TResult Result { get; } /// <summary> /// Gets the exception t...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// A predicate that can be run against a passed <see cref="Exception"/> <paramref name="ex"/>. /// </summary> /// <param name="ex">The passed exception, against which to evaluate the predicate.</param> /// <returns>A matched <see cref="Exception"/>; or null, if an excepti...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// A collection of predicates used to define whether a policy handles a given <see cref="Exception"/>. /// </summary> public class ExceptionPredicates { private List<ExceptionPredicate> _predicates; internal void Add(ExceptionPredicate predicate) { _p...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Fallback; internal static class AsyncFallbackEngine { [DebuggerDisableUserUnhandledExceptions] internal static async Task<TResult> ImplementationAsync<TResult>( Func<Context, CancellationToken, Task<TResult>> action, Context context, Excep...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Fallback; /// <summary> /// A fallback policy that can be applied to asynchronous delegates. /// </summary> public class AsyncFallbackPolicy : AsyncPolicy, IFallbackPolicy { private readonly Func<Exception, Context, Task> _onFallbackAsync; private readonly Func<E...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly; /// <summary> /// Fluent API for defining a Fallback <see cref="AsyncPolicy"/>. /// </summary> public static class AsyncFallbackSyntax { /// <summary> /// Builds an <see cref="AsyncFallbackPolicy"/> which provides a fallback action if the main execution fails. ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>cancellationToken.ThrowIfCancellationRequested(); TResult result = action(context, cancellationToken); if (!shouldHandleResultPredicates.AnyMatch(result)) { return result; } delegateOutcome = new DelegateResult<TResult>(result)...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Fallback; /// <summary> /// A fallback policy that can be applied to delegates. /// </summary> public class FallbackPolicy : Policy, IFallbackPolicy { private readonly Action<Exception, Context> _onFallback; private readonly Action<Exception, Context, Cancellatio...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly; /// <summary> /// Fluent API for defining a Fallback policy. /// </summary> public static class FallbackSyntax { /// <summary> /// Builds a <see cref="FallbackPolicy"/> which provides a fallback action if the main execution fails. Executes the main delegate, but if this thro...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.Fallback; /// <summary> /// Defines properties and methods common to all Fallback policies. /// </summary> public interface IFallbackPolicy : IsPolicy { } /// <summary> /// Defines properties and methods common to all Fallback policies generic-typed for executions retur...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// An interface defining all executions available on an asynchronous policy generic-typed for executions returning results of type <typeparamref name="TResult"/>. /// </summary> /// <typeparam name="TResult">The type of the result of funcs executed through the Policy.</ty...
fim
App-vNext/Polly
csharp
<|fim_suffix|>/returns> /// <exception cref="InvalidOperationException">Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.</exception> Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken ...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// Contains extensions methods on <see cref="IAsyncPolicy"/>. /// </summary> public static class IAsyncPolicyExtensions { /// <summary> /// Converts a non-generic <see cref="IAsyncPolicy"/> into a generic <see cref="IAsyncPolicy{TResult}"/> for handling only execu...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// An interface defining all executions available on a synchronous policy generic-typed for executions returning results of type <typeparamref name="TResult"/>. /// </summary> /// <typeparam name="TResult">The type of the result of funcs executed through the Policy.</type...
fim
App-vNext/Polly
csharp
<|fim_suffix|>icy and returns the captured result. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="action">The action to perform.</param> /// <param name="contextData">Arbitrary data that is passed to the exception policy.</param> /// <param name="ca...
fim
App-vNext/Polly
csharp
<|fim_suffix|>param name="policy">The non-generic <see cref="ISyncPolicy"/> to convert to a generic <see cref="ISyncPolicy{TResult}"/>.</param> /// <returns>A generic <see cref="ISyncPolicy{TResult}"/> version of the supplied non-generic <see cref="ISyncPolicy"/>.</returns> public static ISyncPolicy<TResult> A...
fim
App-vNext/Polly
csharp
<|fim_prefix|>namespace Polly; /// <summary> /// A marker interface identifying Polly policies of all types, and containing properties common to all policies. /// </summary> #pragma warning disable IDE1006 public interface IsPolicy #pragma warning restore IDE1006 { /// <summary> <|fim_suffix|> the <see cref="...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly.NoOp; /// <summary> /// A noop policy that can be applied to asynchronous delegates. /// </summary> public class AsyncNoOpPolicy : AsyncPolicy, INoOpPolicy { internal AsyncNoOpPolicy() { } /// <inheritdoc/> [DebuggerStepThrough] protected override Task<TResult...
fim
App-vNext/Polly
csharp
<|fim_suffix|>licy instance.</returns> public static AsyncNoOpPolicy NoOpAsync() => new(); } <|fim_prefix|>#nullable enable namespace Polly; public partial class Policy { /// <summary> /// Builds a NoOp <see cref="AsyncPolicy"/> that will execute <|fim_middle|>without any custom behavior. /// </summar...
fim
App-vNext/Polly
csharp
#nullable enable namespace Polly; public partial class Policy { /// <summary> /// Builds a NoOp <see cref="AsyncPolicy{TResult}"/> that will execute without any custom behavior. /// </summary> /// <typeparam name="TResult">The type of return values this policy will handle.</typeparam> /// <returns...
fim
App-vNext/Polly
csharp
<|fim_prefix|>#nullable enable namespace Polly.NoOp; /// <summary> /// Defin<|fim_suffix|>> public interface INoOpPolicy<TResult> : INoOpPolicy { } <|fim_middle|>es properties and methods common to all NoOp policies. /// </summary> public interface INoOpPolicy : IsPolicy { } /// <summary> /// Defines properties and ...
fim
App-vNext/Polly
csharp
<|fim_suffix|>en cancellationToken) => action(context, cancellationToken); } <|fim_prefix|>#nullable enable namespace Polly.NoOp; <|fim_middle|> internal static partial class NoOpEngine { internal static TResult Implementation<TResult>(Func<Context, CancellationToken, TResult> action, Context context, Canc...
fim
App-vNext/Polly
csharp
<|fim_suffix|>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken) => action(context, cancellationToken); } <|fim_prefix|>#nullable enable namespace Polly.NoOp; internal static partial class NoOpEngine {<|fim_middle|> internal static Task<TResult> ...
fim
App-vNext/Polly
csharp