-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Azcore cleanup httppipeline apis #3619
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
Merged
alzimmermsft
merged 15 commits into
Azure:master
from
alzimmermsft:azcore_cleanup_httppipeline_apis
May 17, 2019
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
03c47a9
Cleaned up constructors, removed newContext methods
alzimmermsft 84f0d31
Removed pipelinePolicy method and replace it with getPolicy and getPo…
alzimmermsft eb746ce
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft 3892e45
Made index parameter final
alzimmermsft f5bd7a1
Merged in master changes
alzimmermsft dabb997
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft 10a2625
HttpPipeline uses the builder pattern now
alzimmermsft d9c18dc
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft 9c05172
Fixing checkstyle issues
alzimmermsft 3aec25b
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft afe7789
Cleaned up setting policies
alzimmermsft 609c2f6
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft dc7c684
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft e440d37
Merge branch 'master' into azcore_cleanup_httppipeline_apis
alzimmermsft caebdcd
Javadoc cleanup
alzimmermsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
core/azure-core/src/main/java/com/azure/core/http/HttpPipelineBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.http; | ||
|
|
||
| import com.azure.core.http.policy.HttpPipelinePolicy; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * This class provides a fluent builder API to help aid the configuration and instantiation of the {@link HttpPipeline}, | ||
| * calling {@link HttpPipelineBuilder#build() build} constructs an instance of the pipeline. | ||
| * | ||
| * <p>A pipeline is configured with a HttpClient that sends the request, if no client is set a default is used. | ||
| * A pipeline may be configured with a list of policies that are applied to each request.</p> | ||
| * | ||
| * <p><strong>Code Samples</strong></p> | ||
| * | ||
| * <p>Create a pipeline without configuration</p> | ||
| * | ||
| * <pre> | ||
| * HttpPipeline.builder() | ||
| * .build(); | ||
| * </pre> | ||
| * | ||
| * <p>Create a pipeline using the default HTTP client and a retry policy</p> | ||
| * | ||
| * <pre> | ||
| * HttpPipeline.builder() | ||
| * .httpClient(HttpClient.createDefault()) | ||
| * .policies(new RetryPolicy()) | ||
| * .build(); | ||
| * </pre> | ||
| * | ||
| * @see HttpPipeline | ||
| */ | ||
| public class HttpPipelineBuilder { | ||
| private HttpClient httpClient; | ||
| private List<HttpPipelinePolicy> pipelinePolicies; | ||
|
|
||
|
|
||
| HttpPipelineBuilder() { | ||
| } | ||
|
|
||
| /** | ||
| * Creates a {@link HttpPipeline} based on options set in the Builder. Every time {@code build()} is | ||
| * called, a new instance of {@link HttpPipeline} is created. | ||
| * | ||
| * If HttpClient is not set then the {@link HttpClient#createDefault() default HttpClient} is used. | ||
| * | ||
| * @return A HttpPipeline with the options set from the builder. | ||
| */ | ||
| public HttpPipeline build() { | ||
| List<HttpPipelinePolicy> policies = (pipelinePolicies == null) ? new ArrayList<>() : pipelinePolicies; | ||
| HttpClient client = (httpClient == null) ? HttpClient.createDefault() : httpClient; | ||
|
|
||
| return new HttpPipeline(client, policies); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the HttpClient that the pipeline will use to send requests. | ||
| * | ||
| * @param httpClient The HttpClient the pipeline will use when sending requests. | ||
| * @return The updated HttpPipelineBuilder object. | ||
| */ | ||
| public HttpPipelineBuilder httpClient(HttpClient httpClient) { | ||
| this.httpClient = httpClient; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Adds {@link HttpPipelinePolicy policies} to the set of policies that the pipeline will use | ||
| * when sending requests. | ||
| * | ||
| * @param policies Policies to add to the policy set. | ||
| * @return The updated HttpPipelineBuilder object. | ||
| */ | ||
| public HttpPipelineBuilder policies(HttpPipelinePolicy... policies) { | ||
| if (pipelinePolicies == null) { | ||
| pipelinePolicies = new ArrayList<>(); | ||
| } | ||
|
|
||
| this.pipelinePolicies.addAll(Arrays.asList(policies)); | ||
| return this; | ||
| } | ||
alzimmermsft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add header here about code samples, and some explanation text.