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

Decouple multi-address and partitioned client builders from HttpClientBuildContext #2136

Merged
merged 4 commits into from
Mar 9, 2022

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

DefaultMultiAddressHttpClientBuilder and
DefaultPartitionedHttpClientBuilder use
DefaultSingleAddressHttpClientBuilder as a template for underlying
single-address clients. It was helpful before we introduced a
SingleAddressInitializer in #1387. Before that, all builders had the
same set of methods and it was nice to reuse the single-address builder
instead of maintaining a similar state at higher level builders. Now,
SingleAddressInitializer helps to avoid duplication between builders.
We don't have to use DefaultSingleAddressHttpClientBuilder as a
template and can simplify its state by using a factory for
SingleAddressHttpClientBuilder.

Modifications:

  • DefaultMultiAddressUrlHttpClientBuilder and
    DefaultPartitionedHttpClientBuilder use a factory for
    SingleAddressHttpClientBuilder instead of
    DefaultSingleAddressHttpClientBuilder as a template and
    HttpExecutionContextBuilder for context-related items;
  • Remove and hide methods from DefaultSingleAddressHttpClientBuilder
    that are not used by other builders anymore;
  • Add a test to verify DefaultMultiAddressUrlHttpClientBuilder sets
    execution context items for underlying single-address builders;

Result:

DefaultSingleAddressHttpClientBuilder has less pkg-private API,
DefaultMultiAddressUrlHttpClientBuilder and
DefaultPartitionedHttpClientBuilder create a new single-address
builder on demand, similar to grpc builders.

…tBuildContext

Motivation:

`DefaultMultiAddressHttpClientBuilder` and
`DefaultPartitionedHttpClientBuilder` use
`DefaultSingleAddressHttpClientBuilder` as a template for underlying
single-address clients. It was helpful before we introduced a
`SingleAddressInitializer` in apple#1387. Before that, all builders had the
same set of methods and it was nice to reuse the single-address builder
instead of maintaining a similar state at higher level builders. Now,
`SingleAddressInitializer` helps to avoid duplication between builders.
We don't have to use `DefaultSingleAddressHttpClientBuilder` as a
template and can simplify its state by using a factory for
`SingleAddressHttpClientBuilder`.

Modifications:

- `DefaultMultiAddressUrlHttpClientBuilder` and
`DefaultPartitionedHttpClientBuilder` use a factory for
`SingleAddressHttpClientBuilder` instead of
`DefaultSingleAddressHttpClientBuilder` as a template and
`HttpExecutionContextBuilder` for context-related items;
- Remove and hide methods from `DefaultSingleAddressHttpClientBuilder`
that are not used by other builders anymore;
- Add a test to verify `DefaultMultiAddressUrlHttpClientBuilder` sets
execution context items for underlying single-address builders;

Result:

`DefaultSingleAddressHttpClientBuilder` has less pkg-private API,
`DefaultMultiAddressUrlHttpClientBuilder` and
`DefaultPartitionedHttpClientBuilder` create a new single-address
builder on demand, similar to grpc builders.
@idelpivnitskiy
Copy link
Member Author

Another part of the motivation for this change is to be able to intercept when multi-address client initializes a new single-address client builder to make it work for providers in #2137.

@idelpivnitskiy idelpivnitskiy merged commit a93fc9b into apple:main Mar 9, 2022
@idelpivnitskiy idelpivnitskiy deleted the builders-refactoring branch March 9, 2022 23:03
@chemicL
Copy link
Contributor

chemicL commented Mar 10, 2022

Nice! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants