ConnectionResolver class

Helper class to retrieve component connections.

If connections are configured to be retrieved from IDiscovery, it automatically locates IDiscovery in component references and retrieve connections from there using discovery_key parameter.

Configuration parameters

  • connection:

    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • ... other connection parameters
  • connections: alternative to connection

    • connection params 1: first connection parameters
      • ... connection parameters for key 1
    • connection params N: Nth connection parameters
      • ... connection parameters for key N

References

  • *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connections

See ConnectionParams See IDiscovery

Example

var config = ConfigParams.fromTuples(
    'connection.host', '10.1.1.100',
    'connection.port', 8080
);

var connectionResolver = new ConnectionResolver();
connectionResolver.configure(config);
connectionResolver.setReferences(references);

connection await = connectionResolver.resolve('123')
    // Now use connection...

Constructors

ConnectionResolver([ConfigParams? config, IReferences? references])
Creates a new instance of connection resolver.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(ConnectionParams connection) → void
Adds a new connection to component connections
configure(ConfigParams config) → void
Configures component by passing configuration parameters.
getAll() List<ConnectionParams>
Gets all connections configured in component configuration.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(String? correlationId, ConnectionParams connection) Future<ConnectionParams>
Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery.
resolve(String? correlationId) Future<ConnectionParams?>
Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.
resolveAll(String? correlationId) Future<List<ConnectionParams>>
Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.
setReferences(IReferences references) → void
Sets references to dependent components.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited