Class GrpcClientProvider
java.lang.Object
ai.pipestream.dynamic.grpc.client.GrpcClientProvider
Provides creation and lifecycle management of gRPC Mutiny stubs and channels.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of active channels.<T> TGet a Mutiny stub client for a specific host and port.<T> io.smallrye.mutiny.Uni<T> getClientForService(Class<T> stubClass, String serviceName) Get a Mutiny stub client for a service by discovering it from Consul.<T> io.smallrye.mutiny.Uni<T> getClientForServiceUncached(Class<T> stubClass, String serviceName) Get a Mutiny stub client without caching the discovery result.booleanhasChannel(String host, int port) Check if a channel exists for a specific host:port.
-
Constructor Details
-
GrpcClientProvider
public GrpcClientProvider()Default constructor for CDI.
-
-
Method Details
-
getClient
Get a Mutiny stub client for a specific host and port.- Type Parameters:
T- The stub type- Parameters:
stubClass- The Mutiny stub class (e.g., MutinyPipeStepProcessorServiceGrpc.MutinyPipeStepProcessorStub)host- The target hostport- The target port- Returns:
- The Mutiny stub instance
-
getClientForService
Get a Mutiny stub client for a service by discovering it from Consul.- Type Parameters:
T- The stub type- Parameters:
stubClass- The Mutiny stub classserviceName- The Consul service name (e.g., "echo", "test")- Returns:
- A Uni that resolves to the Mutiny stub instance
-
getClientForServiceUncached
public <T> io.smallrye.mutiny.Uni<T> getClientForServiceUncached(Class<T> stubClass, String serviceName) Get a Mutiny stub client without caching the discovery result.- Type Parameters:
T- The stub type- Parameters:
stubClass- The Mutiny stub classserviceName- The Consul service name- Returns:
- A Uni that resolves to the Mutiny stub instance
-
getActiveChannelCount
public int getActiveChannelCount()Get the number of active channels.- Returns:
- the number of ManagedChannel instances currently open
-
hasChannel
Check if a channel exists for a specific host:port.- Parameters:
host- the target hostport- the target port- Returns:
- true if a ManagedChannel for host:port is present in the cache
-