Class MemoryDiscovery

java.lang.Object
org.pipservices3.components.connect.MemoryDiscovery
All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable, org.pipservices3.commons.config.IReconfigurable, IDiscovery

public class MemoryDiscovery
extends Object
implements IDiscovery, org.pipservices3.commons.config.IReconfigurable
Discovery service that keeps connections in memory.

### Configuration parameters ###

  • [connection key 1]:
  • ... connection parameters for key 1
  • [connection key 2]:
  • ... connection parameters for key N

### Example ###

 
 ConfigParams config = ConfigParams.fromTuples(
      "key1.host", "10.1.1.100",
      "key1.port", "8080",
      "key2.host", "10.1.1.100",
      "key2.port", "8082"
 );

 MemoryDiscovery discovery = new MemoryDiscovery();
 discovery.readConnections(config);
 
 discovery.resolve("123", "key1");
 
 
See Also:
IDiscovery, ConnectionParams
  • Constructor Details

    • MemoryDiscovery

      public MemoryDiscovery()
      Creates a new instance of discovery service.
    • MemoryDiscovery

      public MemoryDiscovery​(org.pipservices3.commons.config.ConfigParams config)
      Creates a new instance of discovery service.
      Parameters:
      config - (optional) configuration with connection parameters.
  • Method Details

    • configure

      public void configure​(org.pipservices3.commons.config.ConfigParams config)
      Configures component by passing configuration parameters.
      Specified by:
      configure in interface org.pipservices3.commons.config.IConfigurable
      Parameters:
      config - configuration parameters to be set.
    • readConnections

      public void readConnections​(org.pipservices3.commons.config.ConfigParams connections)
      Reads connections from configuration parameters. Each section represents an individual Connection params
      Parameters:
      connections - configuration parameters to be read
    • register

      public void register​(String correlationId, String key, ConnectionParams connection)
      Registers connection parameters into the discovery service.
      Specified by:
      register in interface IDiscovery
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a key to uniquely identify the connection parameters.
      connection - a connection to be registered.
    • resolveOne

      public ConnectionParams resolveOne​(String correlationId, String key)
      Resolves a single connection parameters by its key.
      Specified by:
      resolveOne in interface IDiscovery
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a key to uniquely identify the connection.
      Returns:
      receives found connection.
    • resolveAll

      public List<ConnectionParams> resolveAll​(String correlationId, String key)
      Resolves all connection parameters by their key.
      Specified by:
      resolveAll in interface IDiscovery
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a key to uniquely identify the connections.
      Returns:
      receives found connections.