public async Task ConfiguringPipeline() { // this instance will hold pipeline creation options var options = ConfigurationClient.CreateDefaultPipelineOptions(); // specify custon HttpClient options.Transport = new HttpClientTransport(s_client); // remove logging policy options.LoggingPolicy = null; // specify custom retry policy options options.RetryPolicy = RetryPolicy.CreateFixed( maxRetries: 10, delay: TimeSpan.FromSeconds(1), retriableCodes: new int[] { 500, // Internal Server Error 504 // Gateway Timeout } ); // add a policy (custom behavior) that executes once per client call options.AddPerCallPolicy(new AddHeaderPolicy()); // add a policy that executes once per retry options.AddPerRetryPolicy(new CustomLogPolicy()); var connectionString = Environment.GetEnvironmentVariable("AZ_CONFIG_CONNECTION"); // pass the policy options to the client var client = new ConfigurationClient(connectionString, options); await client.SetAsync(new ConfigurationSetting("some_key", "some_value")); await client.DeleteAsync("some_key"); }
private static (ConfigurationClient service, TestPool <byte> pool) CreateTestService(MockHttpClientTransport transport) { HttpPipelineOptions options = ConfigurationClient.CreateDefaultPipelineOptions(); var testPool = new TestPool <byte>(); options.AddService(testPool, typeof(ArrayPool <byte>)); options.Transport = transport; var service = new ConfigurationClient(connectionString, options); return(service, testPool); }
public async Task ConfiguringRetries() { // specify retry policy options var options = ConfigurationClient.CreateDefaultPipelineOptions(); options.RetryPolicy = RetryPolicy.CreateFixed( maxRetries: 10, delay: TimeSpan.FromSeconds(1), retriableCodes: new int[] { 500, // Internal Server Error 504 // Gateway Timeout } ); var connectionString = Environment.GetEnvironmentVariable("AZ_CONFIG_CONNECTION"); // pass the policy options to the client var client = new ConfigurationClient(connectionString, options); await client.SetAsync(new ConfigurationSetting("some_key", "some_value")); await client.DeleteAsync("some_key"); }