pip_services3_grpc.services.CommandableGrpcService module
-
class
pip_services3_grpc.services.CommandableGrpcService.
CommandableGrpcService
(name: str) Bases:
pip_services3_grpc.services.GrpcService.GrpcService
,abc.ABC
Abstract service that receives commands via GRPC protocol to operations automatically generated for commands defined in
ICommandable
. Each command is exposed as invoke method that receives command name and parameters.Commandable services require only 3 lines of code to implement a robust external GRPC-based remote interface.
### Configuration parameters ###
- dependencies:
endpoint: override for HTTP 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
### References ### - *: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 <pip_services3_grpc.services.GrpcEndpoint.GrpcEndpoint
reference
See
CommandableGrpcClient <pip_services3_grpc.clients.CommandableGrpcClient.CommandableGrpcClient
,GrpcService <pip_services3_grpc.services.GrpcService.GrpcService
class MyCommandableGrpcService(CommandableGrpcService): def __init__(self): super().__init__('service name') self._dependency_resolver.put( "controller", Descriptor("mygroup","controller","*","*","1.0") ) service = MyCommandableGrpcService() service.configure(ConfigParams.from_tuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 )) service.set_references(References.from_tuples( Descriptor("mygroup","controller","default","default","1.0"), controller )) service.open("123")
-
register
() Registers all service routes in gRPC endpoint. Call automaticaly in open component procedure