pip_services3_grpc.services.GrpcEndpoint module
-
class
pip_services3_grpc.services.GrpcEndpoint.
GrpcEndpoint
Bases:
pip_services3_commons.run.IOpenable.IOpenable
,pip_services3_commons.config.IConfigurable.IConfigurable
,pip_services3_commons.refer.IReferenceable.IReferenceable
Used for creating GRPC endpoints. An endpoint is a URL, at which a given service can be accessed by a client.
### Configuration parameters ###
Parameters to pass to the
configure()
method for component configuration:- connection(s) - the connection resolver’s connections:
“connection.discovery_key” - the key to use for connection resolving in a discovery service;
“connection.protocol” - the connection’s protocol;
“connection.host” - the target host;
“connection.port” - the target port;
“connection.uri” - the target URI.
- credential - the HTTPS credentials:
“credential.ssl_key_file” - the SSL private key in PEM
“credential.ssl_crt_file” - the SSL certificate in PEM
“credential.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
set_references()
method:logger: *:logger:*:*:1.0”;
counters: “*:counters:*:*:1.0”;
discovery: “*:discovery:*:*:1.0” (for the connection resolver).
def my_method(self, _config, _references): endpoint = GrpcEndpoint() if self._config: endpoint.configure(self._config) if self._references: endpoint.set_references(self._references) ... self._endpoint.open(correlation_id) ...
-
close
(correlation_id: Optional[str]) Closes this endpoint and the GRPC server (service) that was opened earlier.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
-
configure
(config: pip_services3_commons.config.ConfigParams.ConfigParams) Configures this HttpEndpoint using the given configuration parameters.
- ### Configuration parameters ###
connection(s) - the connection resolver’s connections;
“connection.discovery_key” - the key to use for connection resolving in a dis
“connection.protocol” - the connection’s protocol;
“connection.host” - the target host;
“connection.port” - the target port;
“connection.uri” - the target URI.
“credential.ssl_key_file” - SSL private key in PEM
“credential.ssl_crt_file” - SSL certificate in PEM
“credential.ssl_ca_file” - Certificate authority (root certificate) in PEM
- Parameters
config – configuration parameters, containing a “connection(s)” section.
-
is_open
() → bool - Returns
whether or not this endpoint is open with an actively listening GRPC server.
-
open
(correlation_id: Optional[str]) Opens a connection using the parameters resolved by the referenced connection resolver and creates a GRPC server (service) using the set options and parameters.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
-
register
(registration: pip_services3_grpc.services.IRegisterable.IRegisterable) Registers a registerable object for dynamic endpoint discovery.
- Parameters
registration – the registration to add.
-
register_service
(service: Any) Registers a service with related implementation
- Parameters
service – a GRPC service object.
-
set_references
(references: pip_services3_commons.refer.IReferences.IReferences) Sets references to this endpoint’s logger, counters, and connection resolver.
__References:__ - logger: “*:logger:*:*:1.0” - counters: “*:counters:*:*:1.0” - discovery: “*:discovery:*:*:1.0” (for the connection resolver)
- Parameters
references – an IReferences object, containing references to a logger, counters, and a connection resolver.
-
unregister
(registration: pip_services3_grpc.services.IRegisterable.IRegisterable) Unregisters a registerable object, so that it is no longer used in dynamic endpoint discovery.
- Parameters
registration – the registration to remove.