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 interface
Initializes the underlyingHttpServerBuilder
used for the transport layer. -
Method Summary
Modifier and TypeMethodDescriptiondefaultTimeout
(Duration defaultTimeout) Set a default timeout during which gRPC calls are expected to complete.default GrpcServerBuilder
defaultTimeout
(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 underlyingHttpServerBuilder
used for the transport layer.lifecycleObserver
(GrpcLifecycleObserver lifecycleObserver) Sets aGrpcLifecycleObserver
that provides visibility into gRPC lifecycle events.listen
(GrpcBindableService<?>... services) Starts this server and returns theGrpcServerContext
after the server has been successfully started.listen
(GrpcServiceFactory<?>... serviceFactories) Starts this server and returns theGrpcServerContext
after the server has been successfully started.listenAndAwait
(GrpcBindableService<?>... services) Starts this server and returns theGrpcServerContext
after the server has been successfully started.listenAndAwait
(GrpcServiceFactory<?>... serviceFactories) Starts this server and returns theGrpcServerContext
after the server has been successfully started.
-
Method Details
-
initializeHttp
Set a function which can configure the underlyingHttpServerBuilder
used 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
-Duration
of 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
-Duration
of default timeout which must be positive non-zero, ornull
if a default shouldn't be applied.appendTimeoutFilter
-true
to append the filter that enforces deadline propagation.false
to not append the filter and therefore not enforce deadlines. Iffalse
you 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 aGrpcLifecycleObserver
that 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
- AGrpcLifecycleObserver
that provides visibility into gRPC lifecycle events.- Returns:
this
.
-
listen
Starts this server and returns theGrpcServerContext
after 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
Single
that 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 theGrpcServerContext
after 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
Single
that 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 theGrpcServerContext
after 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
GrpcServerContext
by blocking the calling thread until the server is successfully started or throws anException
if the server could not be started. - Throws:
Exception
- if the server could not be started.
-
listenAndAwait
Starts this server and returns theGrpcServerContext
after 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
GrpcServerContext
by blocking the calling thread until the server is successfully started or throws anException
if the server could not be started. - Throws:
Exception
- if the server could not be started.
-