Class GrpcController
- All Implemented Interfaces:
org.pipservices4.components.config.IConfigurable,org.pipservices4.components.refer.IReferenceable,org.pipservices4.components.refer.IUnreferenceable,org.pipservices4.components.run.IClosable,org.pipservices4.components.run.IOpenable,IRegisterable
- Direct Known Subclasses:
CommandableGrpcController
### Configuration parameters ###
Parameters to pass to the configure(org.pipservices4.components.config.ConfigParams) method for component configuration:
- dependencies:
- endpoint: override for GRPC Endpoint dependency
- controller: override for Controller dependency
- connection(s):
- discovery_key: (optional) a key to retrieve the connection from IDiscovery
- protocol: connection protocol: http or https
- host: host name or IP address
- port: port number
- uri: resource URI or connection string with all parameters in it
- credential - the HTTPS credentials:
- ssl_key_file: the SSL private key in PEM
- ssl_crt_file: the SSL certificate in PEM
- ssl_ca_file: the certificate authorities (root cerfiticates) in PEM
### References ###
A logger, counters, and a connection resolver can be referenced by passing the
following references to the object's setReferences(org.pipservices4.components.refer.IReferences) method:
- *:logger:*:*:1.0 (optional) ILogger components to pass log messages
- *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements
- *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connection
- *:endpoint:grpc:*:1.0 (optional) GrpcEndpoint reference
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.pipservices4.observability.count.CompositeCountersThe performance counters.protected org.pipservices4.components.refer.DependencyResolverThe dependency resolver.protected GrpcEndpointThe GRPC endpoint that exposes this service.protected org.pipservices4.observability.log.CompositeLoggerThe logger.protected org.pipservices4.observability.trace.CompositeTracerThe tracer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(org.pipservices4.components.context.IContext context) Closes component and frees used resources.voidconfigure(org.pipservices4.components.config.ConfigParams config) Configures component by passing configuration parameters.protected org.pipservices4.rpc.trace.InstrumentTiminginstrument(org.pipservices4.components.context.IContext context, String name) Adds instrumentation to log calls and measure call time.booleanisOpen()Checks if the component is opened.voidopen(org.pipservices4.components.context.IContext context) Opens the component.abstract voidregister()Registers all service routes in Grpc endpoint.protected voidregisterInterceptor(InterceptorFunc action) Registers a middleware for methods in GRPC endpoint.protected <TRequest extends com.google.protobuf.GeneratedMessageV3,TResponse extends com.google.protobuf.GeneratedMessageV3>
voidregisterMethod(String name, org.pipservices4.data.validate.Schema schema, GrpcFunc<TRequest, io.grpc.stub.StreamObserver<TResponse>> action) Registers a method in GRPC service.voidsetReferences(org.pipservices4.components.refer.IReferences references) Sets references to dependent components.voidUnsets (clears) previously set references to dependent components.
-
Field Details
-
_endpoint
The GRPC endpoint that exposes this service. -
_dependencyResolver
protected org.pipservices4.components.refer.DependencyResolver _dependencyResolverThe dependency resolver. -
_logger
protected org.pipservices4.observability.log.CompositeLogger _loggerThe logger. -
_counters
protected org.pipservices4.observability.count.CompositeCounters _countersThe performance counters. -
_tracer
protected org.pipservices4.observability.trace.CompositeTracer _tracerThe tracer.
-
-
Constructor Details
-
GrpcController
public GrpcController(io.grpc.ServiceDescriptor serviceDescriptor)
-
-
Method Details
-
configure
public void configure(org.pipservices4.components.config.ConfigParams config) throws org.pipservices4.commons.errors.ConfigException Configures component by passing configuration parameters.- Specified by:
configurein interfaceorg.pipservices4.components.config.IConfigurable- Parameters:
config- configuration parameters to be set.hnnhhjjnnmmkkkjjhhujnmjjhhhhhh- Throws:
org.pipservices4.commons.errors.ConfigException
-
setReferences
public void setReferences(org.pipservices4.components.refer.IReferences references) throws org.pipservices4.components.refer.ReferenceException, org.pipservices4.commons.errors.ConfigException Sets references to dependent components.- Specified by:
setReferencesin interfaceorg.pipservices4.components.refer.IReferenceable- Parameters:
references- references to locate the component dependencies.- Throws:
org.pipservices4.components.refer.ReferenceExceptionorg.pipservices4.commons.errors.ConfigException
-
unsetReferences
public void unsetReferences()Unsets (clears) previously set references to dependent components.- Specified by:
unsetReferencesin interfaceorg.pipservices4.components.refer.IUnreferenceable
-
instrument
protected org.pipservices4.rpc.trace.InstrumentTiming instrument(org.pipservices4.components.context.IContext context, String name) Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.- Parameters:
context- (optional) a context to trace execution through call chain.name- a method name.- Returns:
- Timing object to end the time measurement.
-
isOpen
public boolean isOpen()Checks if the component is opened.- Specified by:
isOpenin interfaceorg.pipservices4.components.run.IOpenable- Returns:
- true if the component has been opened and false otherwise.
-
open
public void open(org.pipservices4.components.context.IContext context) throws org.pipservices4.commons.errors.ApplicationException Opens the component.- Specified by:
openin interfaceorg.pipservices4.components.run.IOpenable- Parameters:
context- (optional) a context to trace execution through call chain.- Throws:
org.pipservices4.commons.errors.ApplicationException
-
close
public void close(org.pipservices4.components.context.IContext context) throws org.pipservices4.commons.errors.InvalidStateException Closes component and frees used resources.- Specified by:
closein interfaceorg.pipservices4.components.run.IClosable- Parameters:
context- (optional) a context to trace execution through call chain.- Throws:
org.pipservices4.commons.errors.InvalidStateException
-
registerInterceptor
Registers a middleware for methods in GRPC endpoint.- Parameters:
action- an action function that is called when middleware is invoked.
-
registerMethod
protected <TRequest extends com.google.protobuf.GeneratedMessageV3,TResponse extends com.google.protobuf.GeneratedMessageV3> void registerMethod(String name, org.pipservices4.data.validate.Schema schema, GrpcFunc<TRequest, io.grpc.stub.StreamObserver<TResponse>> action) Registers a method in GRPC service.- Parameters:
name- a method nameschema- a validation schema to validate received parameters.action- an action function that is called when operation is invoked.
-
register
public abstract void register()Registers all service routes in Grpc endpoint.This method is called by the service and must be overriden in child classes.
- Specified by:
registerin interfaceIRegisterable
-