Package io.servicetalk.grpc.api
Interface GrpcClientBuilder<U,R>
- Type Parameters:
U- the type of address before resolution (unresolved address)R- the type of address after resolution (resolved address)
- All Known Implementing Classes:
DelegatingGrpcClientBuilder
public interface GrpcClientBuilder<U,R>
A builder for building a gRPC client.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInitializes the underlyingSingleAddressHttpClientBuilderused for the transport layer.static interfaceAn interface to create multiple gRPC clients that share the underlying transport. -
Method Summary
Modifier and TypeMethodDescription<Client extends GrpcClient<?>>
Clientbuild(GrpcClientFactory<Client, ?> clientFactory) Builds a gRPC client.<BlockingClient extends BlockingGrpcClient<?>>
BlockingClientbuildBlocking(GrpcClientFactory<?, BlockingClient> clientFactory) Builds a blocking gRPC client.Returns aGrpcClientBuilder.MultiClientBuilderto be used to create multiple clients that share the underlying transport.defaultTimeout(Duration defaultTimeout) Set default timeout during which gRPC calls are expected to complete.default GrpcClientBuilder<U,R> defaultTimeout(Duration defaultTimeout, boolean appendTimeoutFilter) Set default timeout during which gRPC calls are expected to complete.initializeHttp(GrpcClientBuilder.HttpInitializer<U, R> initializer) Set a function which can configure the underlyingSingleAddressHttpClientBuilderused for the transport layer.
-
Method Details
-
initializeHttp
Set a function which can configure the underlyingSingleAddressHttpClientBuilderused for the transport layer.- Parameters:
initializer- Initializes the underlying HTTP transport builder.- Returns:
this.
-
defaultTimeout
Set default timeout during which gRPC calls are expected to complete. This default will be used only if the request metadata includes no timeout; any value specified in client request will supersede this default.- Parameters:
defaultTimeout-Durationof default timeout which must be positive non-zero.- Returns:
this.- See Also:
-
defaultTimeout
default GrpcClientBuilder<U,R> defaultTimeout(@Nullable Duration defaultTimeout, boolean appendTimeoutFilter) Set default timeout during which gRPC calls are expected to complete. This default will be used only if the request metadata includes no timeout; any value specified in client request will supersede this default.- Parameters:
defaultTimeout-Durationof default timeout which must be positive non-zero, ornullif a default shouldn't be applied.appendTimeoutFilter-trueto append the filter that enforces deadline propagation.falseto not append the filter and therefore not enforce deadlines. Iffalseyou can manually insertGrpcFilters.newGrpcDeadlineClientFilterFactory()in your preferred order useinitializeHttp(io.servicetalk.grpc.api.GrpcClientBuilder.HttpInitializer<U, R>)andSingleAddressHttpClientBuilder.appendClientFilter(StreamingHttpClientFilterFactory).- Returns:
this.- See Also:
-
build
Builds a gRPC client.- Type Parameters:
Client- gRPC service that any client built from this factory represents.- Parameters:
clientFactory-GrpcClientFactoryto use.- Returns:
- A gRPC client.
-
buildBlocking
<BlockingClient extends BlockingGrpcClient<?>> BlockingClient buildBlocking(GrpcClientFactory<?, BlockingClient> clientFactory) Builds a blocking gRPC client.- Type Parameters:
BlockingClient- Blocking gRPC service that any client built from this builder represents.- Parameters:
clientFactory-GrpcClientFactoryto use.- Returns:
- A blocking gRPC client.
-
buildMulti
GrpcClientBuilder.MultiClientBuilder buildMulti()Returns aGrpcClientBuilder.MultiClientBuilderto be used to create multiple clients that share the underlying transport. It is meant for a single backend that hosts different service APIs.
-