Class GrpcServiceRegistry

java.lang.Object
io.micronaut.protobuf.json.registry.GrpcServiceRegistry

@Singleton public class GrpcServiceRegistry extends Object
A class responsible for maintaining a registry of gRPC service methods, enabling them to be exposed and invoked via JSON over REST. The registry manages mappings between service names, method names, and their corresponding ExecutableMethod instances.
The GrpcServiceRegistry is primarily used to support the integration of gRPC methods with REST-based clients by providing a centralized point for method registration and lookup.
Annotations: - @Singleton: Indicates that this class is a singleton within the application context. - @Experimental: Marks the class as experimental functionality, which is subject to change in future releases.
Thread Safety: - This class uses a thread-safe ConcurrentHashMap to store service and method mappings, ensuring safe registration and retrieval in concurrent environments.
  • Constructor Details

    • GrpcServiceRegistry

      public GrpcServiceRegistry()
  • Method Details

    • register

      public void register(Class<?> serviceBeanType, String methodName, io.micronaut.inject.ExecutableMethod<?,?> method)
      Registers a gRPC service method with the internal registry, allowing it to be exposed for invocation via JSON over REST. This method maintains a mapping between the service name, method name, and its corresponding ExecutableMethod.
      Parameters:
      serviceBeanType - The class type of the gRPC service bean being registered. Must not be null.
      methodName - The name of the method in the gRPC service being registered. Must not be null or empty.
      method - The ExecutableMethod representing the method's metadata and logic. Must not be null.
    • getExecutableMethod

      public Optional<io.micronaut.inject.ExecutableMethod<?,?>> getExecutableMethod(String serviceName, String methodName)
      Retrieves an ExecutableMethod instance based on the specified service name and method name. This method is used to locate a registered gRPC method within the given service context.
      Parameters:
      serviceName - The name of the gRPC service containing the method. Must not be null or empty.
      methodName - The name of the method within the service to retrieve. Must not be null or empty.
      Returns:
      An Optional containing the ExecutableMethod if found, or an empty Optional if no matching service or method is registered.