Microsoft.Extensions.Http.Polly Extensions methods for configuring message handlers as part of and message handler pipeline. Adds a which will surround request execution with the provided . The . The . An that can be used to configure the client. See the remarks on for guidance on configuring policies. Adds a which will surround request execution with a policy returned by the . The . Selects an to apply to the current request. An that can be used to configure the client. See the remarks on for guidance on configuring policies. Adds a which will surround request execution with a policy returned by the . The . Selects an to apply to the current request. An that can be used to configure the client. See the remarks on for guidance on configuring policies. Adds a which will surround request execution with a policy returned by the . The . The key used to resolve a policy from the . An that can be used to configure the client. See the remarks on for guidance on configuring policies. Adds a which will surround request execution with a policy returned by the . The . Selects an to apply to the current request. An that can be used to configure the client. See the remarks on for guidance on configuring policies. Adds a which will surround request execution with a created by executing the provided configuration delegate. The policy builder will be preconfigured to trigger application of the policy for requests that fail with conditions that indicate a transient failure. The . A delegate used to create a . An that can be used to configure the client. See the remarks on for guidance on configuring policies. The provided to has been preconfigured errors to handle errors in the following categories: Network failures (as ) HTTP 5XX status codes (server errors) HTTP 408 status code (request timeout) The policy created by will be cached indefinitely per named client. Policies are generally designed to act as singletons, and can be shared when appropriate. To share a policy across multiple named clients, first create the policy and then pass it to multiple calls to as desired. Adds a which will surround request execution with a policy returned by executing provided key selection logic and The . Selects an to apply to the current request based on key selection. A delegate used to generate a policy key based on the . An that can be used to configure the client. Key generated by is first used to lookup existing policies from IPolicyRegistry. If policy does not exist in the registry, create a new policy with and add it in IPolicyRegistry. See the remarks on for guidance on configuring policies. Provides convenience extension methods to register and in the service collection. Registers an empty in the service collection with service types , , and if the service types haven't already been registered and returns the existing or newly created registry. The . The existing or newly created . Registers the provided in the service collection with service types , , and and returns the provided registry. The . The . The provided . Registers an empty in the service collection with service types , , and and uses the specified delegate to configure it. The . A delegate that is used to configure an . The provided . A implementation that executes request processing surrounded by a . This message handler implementation supports the use of policies provided by the Polly library for transient-fault handling and resiliency. The documentation provided here is focused guidance for using Polly together with the . For authoritative information on Polly, see the Polly project and its documentation (). The extension methods on are designed as a convenient and correct way to create a . The method supports the creation of a for any kind of policy. This includes non-reactive policies, such as Timeout or Cache, which don't require the underlying request to fail first. and the convenience methods only accept the generic . Generic policy instances can be created by using the generic methods on such as . To adapt an existing non-generic , use code like the following that converts a non-generic IAsyncPolicy policy to : policy.AsAsyncPolicy<HttpResponseMessage>() The method is an opinionated convenience method that supports the application of a policy for requests that fail due to a connection failure or server error (5XX HTTP status code). This kind of method supports only reactive policies such as Retry, Circuit-Breaker, or Fallback. This method is only provided for convenience; we recommend creating your own policies as needed if this does not meet your requirements. Take care when using policies such as Retry or Timeout together as HttpClient provides its own timeout via . When combining Retry and Timeout, will act as a timeout across all tries; a Polly Timeout policy can be configured after a Retry policy in the configuration sequence, to provide a timeout-per-try. All policies provided by Polly are designed to be efficient when used in a long-lived way. Certain policies such as the Bulkhead and Circuit-Breaker maintain state and should be scoped across calls you wish to share the Bulkhead or Circuit-Breaker state. Take care to ensure the correct lifetimes when using policies and message handlers together in custom scenarios. The extension methods provided by are designed to assign a long lifetime to policies and ensure that they can be used when the handler rotation feature is active. The attaches a context to the prior to executing a , if one does not already exist. The is provided to the policy for use inside the and in other message handlers. Creates a new . The policy. Creates a new . A function which can select the desired policy for a given . Called inside the execution of the to perform request processing. The . The . The . Returns a that will yield a response when completed. The '{0}' function must return a non-null policy instance. To create a policy that takes no action, use '{1}'. The '{0}' function must return a non-null policy instance. To create a policy that takes no action, use '{1}'. Extension methods for Polly integration. Gets the associated with the provided . The . The if set, otherwise null. The will attach a context to the prior to executing a , if one does not already exist. The will be provided to the policy for use inside the and in other message handlers. Sets the associated with the provided . The . The , may be null. The will attach a context to the prior to executing a , if one does not already exist. The will be provided to the policy for use inside the and in other message handlers. Specifies that null is allowed as an input even if the corresponding type disallows it. Specifies that null is disallowed as an input even if the corresponding type allows it. Specifies that an output may be null even if the corresponding type disallows it. Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns. Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter may be null. Gets the return value condition. Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter will not be null. Gets the return value condition. Specifies that the output will be non-null if the named parameter is non-null. Initializes the attribute with the associated parameter name. The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. Gets the associated parameter name. Applied to a method that will never return under any circumstance. Specifies that the method will not return if the associated Boolean parameter is passed the specified value. Initializes the attribute with the specified parameter value. The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to the associated parameter matches this value. Gets the condition parameter value. Specifies that the method or property will ensure that the listed field and property members have not-null values. Initializes the attribute with a field or property member. The field or property member that is promised to be not-null. Initializes the attribute with the list of field and property members. The list of field and property members that are promised to be not-null. Gets field or property member names. Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. Initializes the attribute with the specified return value condition and a field or property member. The return value condition. If the method returns this value, the associated parameter will not be null. The field or property member that is promised to be not-null. Initializes the attribute with the specified return value condition and list of field and property members. The return value condition. If the method returns this value, the associated parameter will not be null. The list of field and property members that are promised to be not-null. Gets the return value condition. Gets field or property member names.