Class GrpcEndpoint

java.lang.Object
org.pipservices4.grpc.controllers.GrpcEndpoint
All Implemented Interfaces:
org.pipservices4.components.config.IConfigurable, org.pipservices4.components.refer.IReferenceable, org.pipservices4.components.run.IClosable, org.pipservices4.components.run.IOpenable

public class GrpcEndpoint extends Object implements org.pipservices4.components.run.IOpenable, org.pipservices4.components.config.IConfigurable, org.pipservices4.components.refer.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(org.pipservices4.components.config.ConfigParams) 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 setReferences(org.pipservices4.components.refer.IReferences) method:

- logger: *:logger:*:*:1.0 - counters: *:counters:*:*:1.0" - discovery: *:discovery:*:*:1.0" (for the connection resolver).

### Example ###

 
 public MyMethod(ConfigParams config, IReferences references) {
     let endpoint = new HttpEndpoint();
     if (this._config)
         endpoint.configure(this._config);
     if (this._references)
         endpoint.setReferences(this._references);
     ...
     this._endpoint.open(context);
 }
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final List<org.pipservices4.grpc.controllers.Interceptor>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(org.pipservices4.components.context.IContext context)
    Closes this endpoint and the GRPC server (service) that was opened earlier.
    void
    configure(org.pipservices4.components.config.ConfigParams config)
    Configures this HttpEndpoint using the given configuration parameters.
    boolean
     
    void
    open(org.pipservices4.components.context.IContext context)
    Opens a connection using the parameters resolved by the referenced connection resolver and creates a GRPC server (service) using the set options and parameters.
    void
    register(IRegisterable registration)
    Registers a registerable object for dynamic endpoint discovery.
    void
    registerService(io.grpc.ServerServiceDefinition service)
    Registers a service with related implementation
    void
    setReferences(org.pipservices4.components.refer.IReferences references)
    Sets references to this endpoint's logger, counters, and connection resolver.
    void
    unregister(IRegisterable registration)
    Unregisters a registerable object, so that it is no longer used in dynamic endpoint discovery.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _interceptors

      protected final List<org.pipservices4.grpc.controllers.Interceptor> _interceptors
  • Constructor Details

    • GrpcEndpoint

      public GrpcEndpoint()
  • Method Details

    • configure

      public void configure(org.pipservices4.components.config.ConfigParams config) throws org.pipservices4.commons.errors.ConfigException
      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 discovery service;
           - "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
       
      Specified by:
      configure in interface org.pipservices4.components.config.IConfigurable
      Parameters:
      config - configuration parameters, containing a "connection(s)" section.
      Throws:
      org.pipservices4.commons.errors.ConfigException
      See Also:
      • (in the PipServices "Commons" package)
    • setReferences

      public void setReferences(org.pipservices4.components.refer.IReferences references) throws org.pipservices4.components.refer.ReferenceException, org.pipservices4.commons.errors.ConfigException
      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)
       
      Specified by:
      setReferences in interface org.pipservices4.components.refer.IReferenceable
      Parameters:
      references - an IReferences object, containing references to a logger, counters, and a connection resolver.
      Throws:
      org.pipservices4.components.refer.ReferenceException
      org.pipservices4.commons.errors.ConfigException
      See Also:
      • (in the PipServices "Commons" package)
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface org.pipservices4.components.run.IOpenable
      Returns:
      whether or not this endpoint is open with an actively listening GRPC server.
    • open

      public void open(org.pipservices4.components.context.IContext context) throws org.pipservices4.commons.errors.ApplicationException
      Opens a connection using the parameters resolved by the referenced connection resolver and creates a GRPC server (service) using the set options and parameters.
      Specified by:
      open in interface org.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)
      Closes this endpoint and the GRPC server (service) that was opened earlier.
      Specified by:
      close in interface org.pipservices4.components.run.IClosable
      Parameters:
      context - (optional) a context to trace execution through call chain.
    • register

      public void register(IRegisterable registration)
      Registers a registerable object for dynamic endpoint discovery.
      Parameters:
      registration - the registration to add.
      See Also:
    • unregister

      public void unregister(IRegisterable registration)
      Unregisters a registerable object, so that it is no longer used in dynamic endpoint discovery.
      Parameters:
      registration - the registration to remove.
      See Also:
    • registerService

      public void registerService(io.grpc.ServerServiceDefinition service)
      Registers a service with related implementation
      Parameters:
      service - a GRPC service object.