PollyHttpClientBuilderExtensions.AddPolicyHandler メソッド

定義

オーバーロード

AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>)

Polly.IAsyncPolicy`1 を指定して要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with the provided Polly.IAsyncPolicy`1.

AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

policySelector から返されるポリシーを含む要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

AddPolicyHandler(IHttpClientBuilder, Func<HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

policySelector から返されるポリシーを含む要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,String,IAsyncPolicy<HttpResponseMessage>>, Func<HttpRequestMessage,String>)

指定したキー選択ロジック keySelector および policyFactory を実行して返されたポリシーを含む、要求の実行を囲む PolicyHttpMessageHandler を追加しますAdds a PolicyHttpMessageHandler which will surround request execution with a policy returned by executing provided key selection logic keySelector and policyFactory

AddPolicyHandler(IHttpClientBuilder, IAsyncPolicy<HttpResponseMessage>)

Polly.IAsyncPolicy`1 を指定して要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with the provided Polly.IAsyncPolicy`1.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddPolicyHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Polly::IAsyncPolicy<System::Net::Http::HttpResponseMessage ^> ^ policy);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddPolicyHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage> policy);
static member AddPolicyHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddPolicyHandler (builder As IHttpClientBuilder, policy As IAsyncPolicy(Of HttpResponseMessage)) As IHttpClientBuilder

パラメーター

policy
Polly.IAsyncPolicy<HttpResponseMessage>

Polly.IAsyncPolicy`1The Polly.IAsyncPolicy`1.

戻り値

IHttpClientBuilder

クライアントを構成するために使用できる IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

注釈

ポリシーの構成については、「」の「解説」を参照してください PolicyHttpMessageHandlerSee the remarks on PolicyHttpMessageHandler for guidance on configuring policies.

AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

policySelector から返されるポリシーを含む要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddPolicyHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::HttpRequestMessage ^, Polly::IAsyncPolicy<System::Net::Http::HttpResponseMessage ^> ^> ^ policySelector);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddPolicyHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.HttpRequestMessage,Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> policySelector);
static member AddPolicyHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.HttpRequestMessage, Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddPolicyHandler (builder As IHttpClientBuilder, policySelector As Func(Of IServiceProvider, HttpRequestMessage, IAsyncPolicy(Of HttpResponseMessage))) As IHttpClientBuilder

パラメーター

policySelector
Func<IServiceProvider,HttpRequestMessage,Polly.IAsyncPolicy<HttpResponseMessage>>

現在の要求に適用する Polly.IAsyncPolicy`1 を選択します。Selects an Polly.IAsyncPolicy`1 to apply to the current request.

戻り値

IHttpClientBuilder

クライアントを構成するために使用できる IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

注釈

ポリシーの構成については、「」の「解説」を参照してください PolicyHttpMessageHandlerSee the remarks on PolicyHttpMessageHandler for guidance on configuring policies.

AddPolicyHandler(IHttpClientBuilder, Func<HttpRequestMessage,IAsyncPolicy<HttpResponseMessage>>)

policySelector から返されるポリシーを含む要求の実行を囲む PolicyHttpMessageHandler を追加します。Adds a PolicyHttpMessageHandler which will surround request execution with a policy returned by the policySelector.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddPolicyHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::HttpRequestMessage ^, Polly::IAsyncPolicy<System::Net::Http::HttpResponseMessage ^> ^> ^ policySelector);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddPolicyHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.HttpRequestMessage,Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> policySelector);
static member AddPolicyHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.HttpRequestMessage, Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddPolicyHandler (builder As IHttpClientBuilder, policySelector As Func(Of HttpRequestMessage, IAsyncPolicy(Of HttpResponseMessage))) As IHttpClientBuilder

パラメーター

policySelector
Func<HttpRequestMessage,Polly.IAsyncPolicy<HttpResponseMessage>>

現在の要求に適用する Polly.IAsyncPolicy`1 を選択します。Selects an Polly.IAsyncPolicy`1 to apply to the current request.

戻り値

IHttpClientBuilder

クライアントを構成するために使用できる IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

注釈

ポリシーの構成については、「」の「解説」を参照してください PolicyHttpMessageHandlerSee the remarks on PolicyHttpMessageHandler for guidance on configuring policies.

AddPolicyHandler(IHttpClientBuilder, Func<IServiceProvider,HttpRequestMessage,String,IAsyncPolicy<HttpResponseMessage>>, Func<HttpRequestMessage,String>)

指定したキー選択ロジック keySelector および policyFactory を実行して返されたポリシーを含む、要求の実行を囲む PolicyHttpMessageHandler を追加しますAdds a PolicyHttpMessageHandler which will surround request execution with a policy returned by executing provided key selection logic keySelector and policyFactory

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddPolicyHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::HttpRequestMessage ^, System::String ^, Polly::IAsyncPolicy<System::Net::Http::HttpResponseMessage ^> ^> ^ policyFactory, Func<System::Net::Http::HttpRequestMessage ^, System::String ^> ^ keySelector);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddPolicyHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.HttpRequestMessage,string,Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> policyFactory, Func<System.Net.Http.HttpRequestMessage,string> keySelector);
static member AddPolicyHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.HttpRequestMessage, string, Polly.IAsyncPolicy<System.Net.Http.HttpResponseMessage>> * Func<System.Net.Http.HttpRequestMessage, string> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddPolicyHandler (builder As IHttpClientBuilder, policyFactory As Func(Of IServiceProvider, HttpRequestMessage, String, IAsyncPolicy(Of HttpResponseMessage)), keySelector As Func(Of HttpRequestMessage, String)) As IHttpClientBuilder

パラメーター

policyFactory
Func<IServiceProvider,HttpRequestMessage,String,Polly.IAsyncPolicy<HttpResponseMessage>>

キーの選択に基づいて現在の要求に適用する Polly.IAsyncPolicy`1 を選択します。Selects an Polly.IAsyncPolicy`1 to apply to the current request based on key selection.

keySelector
Func<HttpRequestMessage,String>

HttpRequestMessage に基づいてポリシー キーを生成するために使用されるデリゲート。A delegate used to generate a policy key based on the HttpRequestMessage.

戻り値

IHttpClientBuilder

クライアントを構成するために使用できる IHttpClientBuilderAn IHttpClientBuilder that can be used to configure the client.

注釈

によって生成されるキー policyFactory は、IPolicyRegistry から既存のポリシーを参照するために最初に使用されます。Key generated by policyFactory is first used to lookup existing policies from IPolicyRegistry. ポリシーがレジストリに存在しない場合は、を使用して新しいポリシーを作成 policyFactory し、IPolicyRegistry に追加します。If policy does not exist in the registry, create a new policy with policyFactory and add it in IPolicyRegistry.

ポリシーの構成については、「」の「解説」を参照してください PolicyHttpMessageHandlerSee the remarks on PolicyHttpMessageHandler for guidance on configuring policies.

適用対象