Class GrpcClientProvider

java.lang.Object
ai.pipestream.dynamic.grpc.client.GrpcClientProvider

@ApplicationScoped public class GrpcClientProvider extends Object
Provides creation and lifecycle management of gRPC Mutiny stubs and channels.
  • Constructor Details

    • GrpcClientProvider

      public GrpcClientProvider()
      Default constructor for CDI.
  • Method Details

    • getClient

      public <T> T getClient(Class<T> stubClass, String host, int port)
      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 host
      port - The target port
      Returns:
      The Mutiny stub instance
    • getClientForService

      public <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.
      Type Parameters:
      T - The stub type
      Parameters:
      stubClass - The Mutiny stub class
      serviceName - 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 class
      serviceName - 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

      public boolean hasChannel(String host, int port)
      Check if a channel exists for a specific host:port.
      Parameters:
      host - the target host
      port - the target port
      Returns:
      true if a ManagedChannel for host:port is present in the cache