resolve method

Future<ConnectionParams?> resolve(
  1. String? correlationId
)

Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

  • correlationId (optional) transaction id to trace execution through call chain. Return Future that receives resolved connection Throws error.

See IDiscovery

Implementation

Future<ConnectionParams?> resolve(String? correlationId) async {
  if (_connections.isEmpty) {
    return null;
  }

  var connections = <ConnectionParams>[];

  for (var index = 0; index < _connections.length; index++) {
    if (!_connections[index].useDiscovery()) {
      return _connections[
          index]; //If a connection is not configured for discovery use - return it.

    } else {
      connections.add(_connections[
          index]); //Otherwise, add it to the list of connections to resolve.
    }
  }

  if (connections.isEmpty) {
    return null;
  }

  ConnectionParams? firstResult;
  for (var connection in connections) {
    var result = await _resolveInDiscovery(correlationId, connection);
    if (result != null) {
      firstResult = result;
      break;
    }
  }
  return firstResult;
}