Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse AddPolicy parameters #7654

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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