Package io.servicetalk.grpc.api
Class GrpcServiceFactory<Filter extends Service,Service extends GrpcService,FilterFactory extends GrpcServiceFilterFactory<Filter,Service>>
- java.lang.Object
-
- io.servicetalk.grpc.api.GrpcServiceFactory<Filter,Service,FilterFactory>
-
- Type Parameters:
Filter
- Type for service filterService
- Type for serviceFilterFactory
- Type for filter factory
public abstract class GrpcServiceFactory<Filter extends Service,Service extends GrpcService,FilterFactory extends GrpcServiceFilterFactory<Filter,Service>> extends java.lang.Object
A factory for binding a gRPC service to a server using aGrpcServiceFactory.ServerBinder
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GrpcServiceFactory.ServerBinder
A utility to bind an HTTP service for gRPC with an appropriate programming model.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GrpcServiceFactory(GrpcRoutes<Service> routes)
Creates new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description GrpcServiceFactory<Filter,Service,FilterFactory>
appendServiceFilter(FilterFactory before)
Appends the passedGrpcServiceFactory
to this factory.protected abstract FilterFactory
appendServiceFilterFactory(FilterFactory existing, FilterFactory append)
Appends the passedGrpcServiceFactory
to this service factory.Single<ServerContext>
bind(GrpcServiceFactory.ServerBinder binder, ExecutionContext executionContext)
Use the passedGrpcServiceFactory.ServerBinder
to bind an appropriate gRPC service for the server.
-
-
-
Constructor Detail
-
GrpcServiceFactory
protected GrpcServiceFactory(GrpcRoutes<Service> routes)
Creates new instance.- Parameters:
routes
-GrpcRoutes
that will hold the routes for the constructed service.
-
-
Method Detail
-
bind
public final Single<ServerContext> bind(GrpcServiceFactory.ServerBinder binder, ExecutionContext executionContext)
Use the passedGrpcServiceFactory.ServerBinder
to bind an appropriate gRPC service for the server.- Parameters:
binder
-GrpcServiceFactory.ServerBinder
to bind gRPC service to the server.executionContext
-ExecutionContext
to use for the service.- Returns:
- A
Single
that completes when the server is successfully started or terminates with an error if the server could not be started.
-
appendServiceFilter
public GrpcServiceFactory<Filter,Service,FilterFactory> appendServiceFilter(FilterFactory before)
Appends the passedGrpcServiceFactory
to this factory.The order of execution of these filters are in order of append. If 3 filters are added as follows:
filter1.append(filter2).append(filter3)
making a request to a client wrapped by this filter chain the order of invocation of these filters will be:filter1 => filter2 => filter3 => client
- Parameters:
before
- the factory to apply before this factory is applied- Returns:
this
-
appendServiceFilterFactory
protected abstract FilterFactory appendServiceFilterFactory(FilterFactory existing, FilterFactory append)
Appends the passedGrpcServiceFactory
to this service factory.- Parameters:
existing
- ExistingGrpcServiceFactory
.append
-GrpcServiceFactory
to append toexisting
.- Returns:
- a composed factory that first applies the
before
factory and then appliesexisting
factory
-
-