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.Object
A factory for creating clients that follows the specified gRPCGrpcClientFactory
contract.
-
-
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 passedGrpcClientFactory
to this factory.protected abstract FilterFactory
appendClientFilterFactory(FilterFactory existing, FilterFactory append)
Appends the passedGrpcClientFactory
to this client factory.protected abstract BlockingClient
newBlockingClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactory
contract using the passedGrpcClientCallFactory
.protected abstract Client
newClient(FilterableClient filterableClient)
Create a newGrpcClientFactory
using the passedGrpcClientFactory
.protected abstract Client
newClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactory
contract using the passedGrpcClientCallFactory
.protected abstract Filter
newFilter(Client client, FilterFactory filterFactory)
protected java.util.List<ContentCodec>
supportedMessageCodings()
Return the supportedContentCodec
s 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 passedGrpcClientFactory
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
-
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 encodingsContentCodec
s for this client.- Returns:
this
-
supportedMessageCodings
protected java.util.List<ContentCodec> supportedMessageCodings()
Return the supportedContentCodec
s for this client factory.- Returns:
- the supported
ContentCodec
s for this client factory
-
appendClientFilterFactory
protected abstract FilterFactory appendClientFilterFactory(FilterFactory existing, FilterFactory append)
Appends the passedGrpcClientFactory
to this client factory.- Parameters:
existing
- ExistingGrpcClientFactory
.append
-GrpcClientFactory
to append toexisting
.- Returns:
- a composed factory that first applies the
before
factory and then appliesexisting
factory
-
newClient
protected abstract Client newClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactory
contract using the passedGrpcClientCallFactory
.- Parameters:
clientCallFactory
-GrpcClientCallFactory
to use for creating client calls. The returnedGrpcClientFactory
should own the lifecycle of this factory.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactory
contract.
-
newFilter
protected abstract Filter newFilter(Client client, FilterFactory filterFactory)
- Parameters:
client
-GrpcClientFactory
to use for creating aGrpcClientFactory
through theGrpcClientFactory
.filterFactory
-GrpcClientFactory
- Returns:
- A
GrpcClientFactory
filtering the passedGrpcClientFactory
.
-
newClient
protected abstract Client newClient(FilterableClient filterableClient)
Create a newGrpcClientFactory
using the passedGrpcClientFactory
.- Parameters:
filterableClient
-GrpcClientFactory
to create aGrpcClientFactory
from.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactory
contract.
-
newBlockingClient
protected abstract BlockingClient newBlockingClient(GrpcClientCallFactory clientCallFactory)
Create a new client that follows the specified gRPCGrpcClientFactory
contract using the passedGrpcClientCallFactory
.- Parameters:
clientCallFactory
-GrpcClientCallFactory
to use for creating client calls. The returnedGrpcClientFactory
should own the lifecycle of this factory.- Returns:
- A new gRPC client following the specified
gRPC
GrpcClientFactory
contract.
-
-