Package io.vertx.grpc.server
Interface Service
-
- All Known Subinterfaces:
GrpcIoServiceBridge
public interface Service
Provides metadata about a gRPC service.This interface gives access to both the name and the service descriptor, which contains detailed information about the service's methods, input and output types, and other metadata defined in the protobuf service definition.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
bind(GrpcServer server)
Binds this service and all its registered method handlers to the specified gRPC server.com.google.protobuf.Descriptors.ServiceDescriptor
descriptor()
Get the service descriptor that contains detailed information about the service.default boolean
hasMethod(String methodName)
Check if a method exists in this service.default Optional<com.google.protobuf.Descriptors.MethodDescriptor>
methodDescriptor(String methodName)
Get a method descriptor by service.default List<com.google.protobuf.Descriptors.MethodDescriptor>
methodDescriptors()
Get a list of all method descriptors for this service.ServiceName
name()
Get the name of the service.default String
pathOfMethod(String methodName)
Get the full path for a method, which can be used for making gRPC calls.static ServiceBuilder
service(ServiceName serviceName, com.google.protobuf.Descriptors.ServiceDescriptor descriptor)
Creates a new Service instance with the specified service name and descriptor.
-
-
-
Method Detail
-
service
static ServiceBuilder service(ServiceName serviceName, com.google.protobuf.Descriptors.ServiceDescriptor descriptor)
Creates a new Service instance with the specified service name and descriptor.- Parameters:
serviceName
- the name of the gRPC servicedescriptor
- the service descriptor- Returns:
- a new Service instance
-
name
ServiceName name()
Get the name of the service.- Returns:
- the name of the service
-
descriptor
com.google.protobuf.Descriptors.ServiceDescriptor descriptor()
Get the service descriptor that contains detailed information about the service.- Returns:
- the service descriptor
-
bind
void bind(GrpcServer server)
Binds this service and all its registered method handlers to the specified gRPC server. This allows the server to handle requests for this service.- Parameters:
server
- the gRPC server to bind this service to
-
methodDescriptors
default List<com.google.protobuf.Descriptors.MethodDescriptor> methodDescriptors()
Get a list of all method descriptors for this service.- Returns:
- list of method descriptors
-
methodDescriptor
default Optional<com.google.protobuf.Descriptors.MethodDescriptor> methodDescriptor(String methodName)
Get a method descriptor by service.- Parameters:
methodName
- the service of the method- Returns:
- an Optional containing the method descriptor if found, or empty if not found
-
hasMethod
default boolean hasMethod(String methodName)
Check if a method exists in this service.- Parameters:
methodName
- the name of the method to check- Returns:
- true if the method exists, false otherwise
-
pathOfMethod
default String pathOfMethod(String methodName)
Get the full path for a method, which can be used for making gRPC calls. The format is "/package.ServiceName/MethodName".- Parameters:
methodName
- the name of the method- Returns:
- the full path for the method
- Throws:
IllegalArgumentException
- if the method does not exist
-
-