Skip to content
This repository was archived by the owner on Nov 17, 2018. It is now read-only.
This repository was archived by the owner on Nov 17, 2018. It is now read-only.

Scope of Polly polices in relation to named HttpClient configurations  #60

@reisenberger

Description

@reisenberger

Not so much an issue as drawing out the below implication, and noting it for consideration for documentation

Scope of Polly polices in relation to named HttpClient configurations

Ensuring circuit-breaker and bulkhead policies maintain consistent state while handlers and HttpClient instances are recycled underneath them, has suggested they should be singleton per named HttpClient configuration on HttpClientFactory.

The stateful nature of circuit-breaker and bulkhead policies also has intended functional consequences when sharing policies across call sites:

Circuit-breaker: Sharing a CircuitBreakerPolicy instance at multiple call sites causes those call sites to share circuit statistics and state, and thus to break in common.

This is intended: for example, using the same CircuitBreakerPolicy instance for all calls to (various endpoints on) contoso.com means any call you place to any endpoint on contoso.com can know if other calls have already detected that contoso.com is 'down' (and broken the circuit).

Bulkhead: Calls placed through the same BulkheadPoliy instance share the capacity of that bulkhead.


The corollary of this for HttpClientFactory is:

Circuit-breaker: Where a named HttpClient configuration on an HttpClientFactory uses a CircuitBreakerPolicy, that named HttpClient should be usage-scoped to calls to endpoints the user wishes to break in common.

This is a good fit for the examples @rynowak / @glennc have given for HttpClientFactory, with eg a named client configuration of "github" being used with a BaseUri "github.com" (with the implication calls through it will be to somewhere on github.com).

Bulkhead: Similarly, a named HttpClient configuration, if configured with a BulkheadPolicy, should be usage-scoped to calls the user wishes to share that bulkhead capacity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions