Package io.servicetalk.grpc.api
Interface GrpcServerBuilder
- All Known Implementing Classes:
DelegatingGrpcServerBuilder
public interface GrpcServerBuilder
A builder for building a gRPC server.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInitializes the underlyingHttpServerBuilderused for the transport layer. -
Method Summary
Modifier and TypeMethodDescriptiondefaultTimeout(Duration defaultTimeout) Set a default timeout during which gRPC calls are expected to complete.default GrpcServerBuilderdefaultTimeout(Duration defaultTimeout, boolean appendTimeoutFilter) Set a default timeout during which gRPC calls are expected to complete.initializeHttp(GrpcServerBuilder.HttpInitializer initializer) Set a function which can configure the underlyingHttpServerBuilderused for the transport layer.lifecycleObserver(GrpcLifecycleObserver lifecycleObserver) Sets aGrpcLifecycleObserverthat provides visibility into gRPC lifecycle events.listen(GrpcBindableService<?>... services) Starts this server and returns theGrpcServerContextafter the server has been successfully started.listen(GrpcServiceFactory<?>... serviceFactories) Starts this server and returns theGrpcServerContextafter the server has been successfully started.listenAndAwait(GrpcBindableService<?>... services) Starts this server and returns theGrpcServerContextafter the server has been successfully started.listenAndAwait(GrpcServiceFactory<?>... serviceFactories) Starts this server and returns theGrpcServerContextafter the server has been successfully started.
-
Method Details
-
initializeHttp
Set a function which can configure the underlyingHttpServerBuilderused for the transport layer.- Parameters:
initializer- Initializes the underlying HTTP transport builder.- Returns:
this.
-
defaultTimeout
Set a default timeout during which gRPC calls are expected to complete. This default will be used only if the request 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 GrpcServerBuilder defaultTimeout(@Nullable Duration defaultTimeout, boolean appendTimeoutFilter) Set a default timeout during which gRPC calls are expected to complete. This default will be used only if the request 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.newGrpcDeadlineServerFilterFactory(Duration)in your preferred order useinitializeHttp(io.servicetalk.grpc.api.GrpcServerBuilder.HttpInitializer)andHttpServerBuilder.appendNonOffloadingServiceFilter(StreamingHttpServiceFilterFactory)(to force ordering before any offloading filters) orHttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory)(if you require different ordering).- Returns:
this.
-
lifecycleObserver
Sets aGrpcLifecycleObserverthat provides visibility into gRPC lifecycle events.Note, if
initializeHttp(HttpInitializer)is used to configureHttpServerBuilder.lifecycleObserver(HttpLifecycleObserver)– that will override the value specified using this method. Please choose only one approach.- Parameters:
lifecycleObserver- AGrpcLifecycleObserverthat provides visibility into gRPC lifecycle events.- Returns:
this.
-
listen
Starts this server and returns theGrpcServerContextafter the server has been successfully started.If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on
address.- Parameters:
services-GrpcBindableService(s) to create a gRPC service.- Returns:
- A
Singlethat completes when the server is successfully started or terminates with an error if the server could not be started.
-
listen
Starts this server and returns theGrpcServerContextafter the server has been successfully started.If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on
address.- Parameters:
serviceFactories-GrpcServiceFactory(s) to create a gRPC service.- Returns:
- A
Singlethat completes when the server is successfully started or terminates with an error if the server could not be started.
-
listenAndAwait
Starts this server and returns theGrpcServerContextafter the server has been successfully started.If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on
address.- Parameters:
serviceFactories-GrpcServiceFactory(s) to create a gRPC service.- Returns:
- A
GrpcServerContextby blocking the calling thread until the server is successfully started or throws anExceptionif the server could not be started. - Throws:
Exception- if the server could not be started.
-
listenAndAwait
Starts this server and returns theGrpcServerContextafter the server has been successfully started.If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on
address.- Parameters:
services-GrpcBindableService(s) to create a gRPC service.- Returns:
- A
GrpcServerContextby blocking the calling thread until the server is successfully started or throws anExceptionif the server could not be started. - Throws:
Exception- if the server could not be started.
-