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 Summary
Constructors Constructor Description MemoryDiscovery()Creates a new instance of discovery service.MemoryDiscovery(org.pipservices3.commons.config.ConfigParams config)Creates a new instance of discovery service. -
Method Summary
Modifier and Type Method Description voidconfigure(org.pipservices3.commons.config.ConfigParams config)Configures component by passing configuration parameters.voidreadConnections(org.pipservices3.commons.config.ConfigParams connections)Reads connections from configuration parameters.voidregister(String correlationId, String key, ConnectionParams connection)Registers connection parameters into the discovery service.List<ConnectionParams>resolveAll(String correlationId, String key)Resolves all connection parameters by their key.ConnectionParamsresolveOne(String correlationId, String key)Resolves a single connection parameters by its key.
-
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:
configurein interfaceorg.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
Registers connection parameters into the discovery service.- Specified by:
registerin interfaceIDiscovery- 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
Resolves a single connection parameters by its key.- Specified by:
resolveOnein interfaceIDiscovery- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.key- a key to uniquely identify the connection.- Returns:
- receives found connection.
-
resolveAll
Resolves all connection parameters by their key.- Specified by:
resolveAllin interfaceIDiscovery- Parameters:
correlationId- (optional) transaction id to trace execution through call chain.key- a key to uniquely identify the connections.- Returns:
- receives found connections.
-