servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/HttpClients.java
/**
     * Creates a {@link PartitionedHttpClientBuilder} for a custom address type with default {@link LoadBalancer} and
     * user provided {@link ServiceDiscoverer}.
     *
     * @param serviceDiscoverer The {@link ServiceDiscoverer} to resolve addresses of remote servers to connect to.
     * The lifecycle of the provided {@link ServiceDiscoverer} should be managed by the caller.
     * @param address the {@code UnresolvedAddress} to resolve using the provided {@code serviceDiscoverer}.
     * This address will also be used for the {@link HttpHeaderNames#HOST} using a best effort conversion. Use {@link
     * PartitionedHttpClientBuilder#unresolvedAddressToHost(Function)} if you want to override that value or
     * {@link PartitionedHttpClientBuilder#disableHostHeaderFallback()} if you want to disable this behavior.
     * @param partitionAttributesBuilderFactory The factory {@link Function} used to build {@link PartitionAttributes}
     * from {@link HttpRequestMetaData}.
     * @param <U> the type of address before resolution (unresolved address)
     * @param <R> the type of address after resolution (resolved address)
     * @return new builder with provided configuration
     */
Creates a  PartitionedHttpClientBuilder for a custom address type with default  LoadBalancer and
user provided  ServiceDiscoverer.

@param serviceDiscoverer The  ServiceDiscoverer to resolve addresses of remote servers to connect to.
The lifecycle of the provided  ServiceDiscoverer should be managed by the caller.
@param address the  UnresolvedAddress to resolve using the provided  serviceDiscoverer.
This address will also be used for the  HttpHeaderNames#HOST using a best effort conversion. Use {@link
PartitionedHttpClientBuilder#unresolvedAddressToHost(Function)} if you want to override that value or
PartitionedHttpClientBuilder#disableHostHeaderFallback() if you want to disable this behavior.
@param partitionAttributesBuilderFactory The factory  Function used to build  PartitionAttributes
from  HttpRequestMetaData.
@param  the type of address before resolution (unresolved address)
@param  the type of address after resolution (resolved address)
@return new builder with provided configuration
Creates a PartitionedHttpClientBuilder for a custom address type with default LoadBalancer and user provided ServiceDiscoverer . @param serviceDiscoverer The ServiceDiscoverer to resolve addresses of remote servers to connect to . The lifecycle of the provided ServiceDiscoverer should be managed by the caller . @param address the UnresolvedAddress to resolve using the provided serviceDiscoverer . This address will also be used for the HttpHeaderNames#HOST using a best effort conversion . Use { @link PartitionedHttpClientBuilder#unresolvedAddressToHost ( Function ) } if you want to override that value or PartitionedHttpClientBuilder#disableHostHeaderFallback () if you want to disable this behavior . @param partitionAttributesBuilderFactory The factory Function used to build PartitionAttributes from HttpRequestMetaData . @param the type of address before resolution ( unresolved address ) @param the type of address after resolution ( resolved address ) @return new builder with provided configuration
public static <U, R> PartitionedHttpClientBuilder<U, R> forPartitionedAddress(
            final ServiceDiscoverer<U, R, PartitionedServiceDiscovererEvent<R>> serviceDiscoverer,
            final U address,
            final Function<HttpRequestMetaData, PartitionAttributesBuilder> partitionAttributesBuilderFactory) {
        return new DefaultPartitionedHttpClientBuilder<>(
                new DefaultSingleAddressHttpClientBuilder<>(address,
                        new ServiceDiscoverer<U, R, ServiceDiscovererEvent<R>>() {
                            private final ListenableAsyncCloseable closeable = emptyAsyncCloseable();
                            @Override
                            public Publisher<Collection<ServiceDiscovererEvent<R>>> discover(final U u) {
                                return failed(new IllegalStateException("Invalid service discoverer."));
                            }
                            @Override
                            public Completable onClose() {
                                return closeable.onClose();
                            }
                            @Override
                            public Completable closeAsync() {
                                return closeable.closeAsync();
                            }
                            @Override
                            public Completable closeAsyncGracefully() {
                                return closeable.closeAsyncGracefully();
                            }
                        }), serviceDiscoverer, partitionAttributesBuilderFactory);
    }
public static < U , R > PartitionedHttpClientBuilder < U , R > forPartitionedAddress ( final ServiceDiscoverer < U , R , PartitionedServiceDiscovererEvent < R > > serviceDiscoverer , final U address , final Function < HttpRequestMetaData , PartitionAttributesBuilder > partitionAttributesBuilderFactory ) { return new DefaultPartitionedHttpClientBuilder < > ( new DefaultSingleAddressHttpClientBuilder < > ( address , new ServiceDiscoverer < U , R , ServiceDiscovererEvent < R > > ( ) { private final ListenableAsyncCloseable closeable = emptyAsyncCloseable ( ) ; @ Override public Publisher < Collection < ServiceDiscovererEvent < R > > > discover ( final U u ) { return failed ( new IllegalStateException ( "Invalid service discoverer." ) ) ; } @ Override public Completable onClose ( ) { return closeable . onClose ( ) ; } @ Override public Completable closeAsync ( ) { return closeable . closeAsync ( ) ; } @ Override public Completable closeAsyncGracefully ( ) { return closeable . closeAsyncGracefully ( ) ; } } ) , serviceDiscoverer , partitionAttributesBuilderFactory ) ; }
Creates a {@link PartitionedHttpClientBuilder} for a custom address type with default {@link LoadBalancer} and
 user provided {@link ServiceDiscoverer}.
Creates a { @link PartitionedHttpClientBuilder } for a custom address type with default { @link LoadBalancer } and user provided { @link ServiceDiscoverer } .