Skip to content

Commit

Permalink
Reverse AddPolicy parameters (Azure#7654)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Sep 17, 2019
1 parent 612402f commit ef4f5d5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public void ConfiguringPipeline()
options.Retry.Delay = TimeSpan.FromSeconds(1);

// add a policy (custom behavior) that executes once per client call
options.AddPolicy(HttpPipelinePosition.PerCall, new AddHeaderPolicy());
options.AddPolicy(new AddHeaderPolicy(), HttpPipelinePosition.PerCall);

// add a policy that executes once per retry
options.AddPolicy(HttpPipelinePosition.PerRetry, new CustomLogPolicy());
options.AddPolicy(new CustomLogPolicy(), HttpPipelinePosition.PerRetry);

var connectionString = Environment.GetEnvironmentVariable("APPCONFIGURATION_CONNECTION_STRING");
// pass the policy options to the client
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/Pipeline/HttpPipelineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public HttpPipelineTransport Transport

public RetryOptions Retry { get; }

public void AddPolicy(HttpPipelinePosition position, HttpPipelinePolicy policy)
public void AddPolicy(HttpPipelinePolicy policy, HttpPipelinePosition position)
{
switch (position)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/tests/HttpPipelineBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task CanAddCustomPolicy(HttpPipelinePosition position, int expected
var transport = new MockTransport(new MockResponse(503), new MockResponse(200));

var options = new TestOptions();
options.AddPolicy(position, policy);
options.AddPolicy(policy, position);
options.Transport = transport;

HttpPipeline pipeline = HttpPipelineBuilder.Build(options);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Microsoft.Extensions.Azure/samples/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void ConfigureServices(IServiceCollection services)
builder.ConfigureDefaults(options => options.Retry.Mode = RetryMode.Exponential);

// Advanced configure global defaults
builder.ConfigureDefaults((options, provider) => options.AddPolicy(HttpPipelinePosition.PerCall, provider.GetService<DependencyInjectionEnabledPolicy>()));
builder.ConfigureDefaults((options, provider) => options.AddPolicy(provider.GetService<DependencyInjectionEnabledPolicy>(), HttpPipelinePosition.PerCall));

builder.AddBlobServiceClient(Configuration.GetSection("Storage"))
.WithVersion(BlobClientOptions.ServiceVersion.V2018_11_09);
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public BlobClientOptions GetFaultyBlobConnectionOptions(
{
raise = raise ?? new Exception("Simulated connection fault");
var options = this.GetOptions();
options.AddPolicy(HttpPipelinePosition.PerCall, new FaultyDownloadPipelinePolicy(raiseAt, raise));
options.AddPolicy(new FaultyDownloadPipelinePolicy(raiseAt, raise), HttpPipelinePosition.PerCall);
return options;
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Files/tests/FileTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public FileClientOptions GetFaultyFileConnectionOptions(
{
raise = raise ?? new IOException("Simulated connection fault");
var options = this.GetOptions();
options.AddPolicy(HttpPipelinePosition.PerCall, new FaultyDownloadPipelinePolicy(raiseAt, raise));
options.AddPolicy(new FaultyDownloadPipelinePolicy(raiseAt, raise), HttpPipelinePosition.PerCall);
return options;
}

Expand Down

0 comments on commit ef4f5d5

Please sign in to comment.