Package io.servicetalk.grpc.api
Class GrpcClientFactory<Client extends GrpcClient<BlockingClient>,BlockingClient extends BlockingGrpcClient<Client>,Filter extends FilterableClient,FilterableClient extends FilterableGrpcClient,FilterFactory extends GrpcClientFilterFactory<Filter,FilterableClient>>
- java.lang.Object
-
- io.servicetalk.grpc.api.GrpcClientFactory<Client,BlockingClient,Filter,FilterableClient,FilterFactory>
-
- Type Parameters:
Client- gRPC service that any client built from this factory represents.BlockingClient- Blocking gRPC service that any client built from this builder represents.Filter- Type for client filterFilterableClient- Type of filterable client.FilterFactory- Type ofGrpcClientFilterFactory
public abstract class GrpcClientFactory<Client extends GrpcClient<BlockingClient>,BlockingClient extends BlockingGrpcClient<Client>,Filter extends FilterableClient,FilterableClient extends FilterableGrpcClient,FilterFactory extends GrpcClientFilterFactory<Filter,FilterableClient>> extends java.lang.ObjectA factory for creating clients that follows the specified gRPCGrpcClientFactorycontract.
-
-
Constructor Summary
Constructors Constructor Description GrpcClientFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description GrpcClientFactory<Client,BlockingClient,Filter,FilterableClient,FilterFactory>appendClientFilter(FilterFactory before)Appends the passedGrpcClientFactoryto this factory.protected abstract FilterFactoryappendClientFilterFactory(FilterFactory existing, FilterFactory append)Appends the passedGrpcClientFactoryto this client factory.protected abstract BlockingClientnewBlockingClient(GrpcClientCallFactory clientCallFactory)Create a new client that follows the specified gRPCGrpcClientFactorycontract using the passedGrpcClientCallFactory.protected abstract ClientnewClient(FilterableClient filterableClient)Create a newGrpcClientFactoryusing the passedGrpcClientFactory.protected abstract ClientnewClient(GrpcClientCallFactory clientCallFactory)Create a new client that follows the specified gRPCGrpcClientFactorycontract using the passedGrpcClientCallFactory.protected abstract FilternewFilter(Client client, FilterFactory filterFactory)protected java.util.List<ContentCodec>supportedMessageCodings()Return the supportedContentCodecs for this client factory.GrpcClientFactory<Client,BlockingClient,Filter,FilterableClient,FilterFactory>supportedMessageCodings(java.util.List<ContentCodec> codings)Sets the supported message encodings for this client factory.
-
-
-
Method Detail
-
appendClientFilter
public GrpcClientFactory<Client,BlockingClient,Filter,FilterableClient,FilterFactory> appendClientFilter(FilterFactory before)
Appends the passedGrpcClientFactoryto 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
-
supportedMessageCodings
public GrpcClientFactory<Client,BlockingClient,Filter,FilterableClient,FilterFactory> supportedMessageCodings(java.util.List<ContentCodec> codings)
Sets the supported message encodings for this client factory. By default onlyIdentity.identity()is supported- Parameters:
codings- The supported encodingsContentCodecs for this client.- Returns:
this
-
supportedMessageCodings
protected java.util.List<ContentCodec> supportedMessageCodings()
Return the supportedContentCodecs for this client factory.- Returns:
- the supported
ContentCodecs for this client factory
-
appendClientFilterFactory
protected abstract FilterFactory appendClientFilterFactory(FilterFactory existing, FilterFactory append)
Appends the passedGrpcClientFactoryto this client factory.- Parameters:
existing- ExistingGrpcClientFactory.append-GrpcClientFactoryto append toexisting.- Returns:
- a composed factory that first applies the
beforefactory and then appliesexistingfactory
-
newClient
protected abstract Client newClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactorycontract using the passedGrpcClientCallFactory.- Parameters:
clientCallFactory-GrpcClientCallFactoryto use for creating client calls. The returnedGrpcClientFactoryshould own the lifecycle of this factory.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactorycontract.
-
newFilter
protected abstract Filter newFilter(Client client, FilterFactory filterFactory)
- Parameters:
client-GrpcClientFactoryto use for creating aGrpcClientFactorythrough theGrpcClientFactory.filterFactory-GrpcClientFactory- Returns:
- A
GrpcClientFactoryfiltering the passedGrpcClientFactory.
-
newClient
protected abstract Client newClient(FilterableClient filterableClient)
Create a newGrpcClientFactoryusing the passedGrpcClientFactory.- Parameters:
filterableClient-GrpcClientFactoryto create aGrpcClientFactoryfrom.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactorycontract.
-
newBlockingClient
protected abstract BlockingClient newBlockingClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactorycontract using the passedGrpcClientCallFactory.- Parameters:
clientCallFactory-GrpcClientCallFactoryto use for creating client calls. The returnedGrpcClientFactoryshould own the lifecycle of this factory.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactorycontract.
-
-