title: Polly circuit Breaker policy using IServiceProvider
body: <p>I need to add a circuit breaker policy to few of my <code>HttpClient</code>s. Therefore I have to share my circuit breaker policy with all clients.</p>
  <pre class="lang-cs prettyprint-override"><code>public static AsyncCircuitBreakerPolicy circuitBreaker = Policy
      .Handle&lt;Exception&gt;()
      .CircuitBreakerAsync(1, TimeSpan.FromSeconds(30),
          (exception, timespan, context) =&gt; { },
          context =&gt; { }
      );
  </code></pre>
  <p>But I need to access <code>IServiceProvider</code> to get another service to do some actions on break circuit. e.g.</p>
  <pre class="lang-cs prettyprint-override"><code>Action&lt;Exception, TimeSpan, Context&gt; onBreak = (exception, timespan, context) =&gt;
  {
      var service = serviceProvider.GetService&lt;IService&gt;();
      service.CircuitBroken();
  };
  </code></pre>
  <p>How can I achieve this?</p>
  <p>I'm planing to call  <code>AddPolicyHandler</code> on my client. But then for it will be a new instance of circuitBreaker policy.</p>
  <pre class="lang-cs prettyprint-override"><code>serviceCollection
      .AddHttpClient&lt;IClient1, Client1&gt;()
      .AddPolicyHandler((serviceProvider, request) =&gt;
          GetCircuitBreakerPolicy(serviceProvider));
  </code></pre>