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.ObjectA factory for binding a gRPC service to a server using aGrpcServiceFactory.ServerBinder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGrpcServiceFactory.ServerBinderA utility to bind an HTTP service for gRPC with an appropriate programming model.
-
Constructor Summary
Constructors Modifier Constructor Description protectedGrpcServiceFactory(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 passedGrpcServiceFactoryto this factory.protected abstract FilterFactoryappendServiceFilterFactory(FilterFactory existing, FilterFactory append)Appends the passedGrpcServiceFactoryto this service factory.Single<ServerContext>bind(GrpcServiceFactory.ServerBinder binder, ExecutionContext executionContext)Use the passedGrpcServiceFactory.ServerBinderto bind an appropriate gRPC service for the server.
-
-
-
Constructor Detail
-
GrpcServiceFactory
protected GrpcServiceFactory(GrpcRoutes<Service> routes)
Creates new instance.- Parameters:
routes-GrpcRoutesthat will hold the routes for the constructed service.
-
-
Method Detail
-
bind
public final Single<ServerContext> bind(GrpcServiceFactory.ServerBinder binder, ExecutionContext executionContext)
Use the passedGrpcServiceFactory.ServerBinderto bind an appropriate gRPC service for the server.- Parameters:
binder-GrpcServiceFactory.ServerBinderto bind gRPC service to the server.executionContext-ExecutionContextto use for the service.- Returns:
- A
Singlethat 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 passedGrpcServiceFactoryto 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 passedGrpcServiceFactoryto this service factory.- Parameters:
existing- ExistingGrpcServiceFactory.append-GrpcServiceFactoryto append toexisting.- Returns:
- a composed factory that first applies the
beforefactory and then appliesexistingfactory
-
-