Class DynamicGrpcClientFactory
java.lang.Object
ai.pipestream.dynamic.grpc.client.DynamicGrpcClientFactory
- All Implemented Interfaces:
GrpcClientFactory
@ApplicationScoped
public class DynamicGrpcClientFactory
extends Object
implements GrpcClientFactory
Factory for creating Mutiny gRPC clients using dynamic service discovery.
This factory ensures the service is defined in Stork, discovers instances,
obtains a Channel from ChannelManager, and produces Mutiny stubs on demand.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNameResolverProvider that uses SmallRye Stork to resolve service instances for a logical service name into gRPC address groups. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidevictChannel(String serviceName) Evict (close) a cached channel for a service to force reconnection.intGet the number of active service connections being managed.Get cache statistics for debugging and monitoring.io.smallrye.mutiny.Uni<io.grpc.Channel> getChannel(String serviceName) Get a raw Channel for advanced use cases.<T extends io.quarkus.grpc.MutinyStub>
io.smallrye.mutiny.Uni<T> Get a typed Mutiny stub using a method reference (zero reflection).
-
Constructor Details
-
DynamicGrpcClientFactory
public DynamicGrpcClientFactory()Default constructor for CDI frameworks.
-
-
Method Details
-
getClient
public <T extends io.quarkus.grpc.MutinyStub> io.smallrye.mutiny.Uni<T> getClient(String serviceName, Function<io.grpc.Channel, T> stubCreator) Get a typed Mutiny stub using a method reference (zero reflection).- Specified by:
getClientin interfaceGrpcClientFactory- Type Parameters:
T- The Mutiny stub type (must extend MutinyStub)- Parameters:
serviceName- The logical service name for discoverystubCreator- Method reference to create stub (e.g., MutinyFooServiceGrpc::newMutinyStub)- Returns:
- A Uni emitting the typed Stub
-
getChannel
Description copied from interface:GrpcClientFactoryGet a raw Channel for advanced use cases.- Specified by:
getChannelin interfaceGrpcClientFactory- Parameters:
serviceName- The logical service name for discovery- Returns:
- A Uni emitting the Channel
-
getActiveServiceCount
public int getActiveServiceCount()Description copied from interface:GrpcClientFactoryGet the number of active service connections being managed.- Specified by:
getActiveServiceCountin interfaceGrpcClientFactory
-
evictChannel
Description copied from interface:GrpcClientFactoryEvict (close) a cached channel for a service to force reconnection.- Specified by:
evictChannelin interfaceGrpcClientFactory
-
getCacheStats
Description copied from interface:GrpcClientFactoryGet cache statistics for debugging and monitoring.- Specified by:
getCacheStatsin interfaceGrpcClientFactory
-