resolve method

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

Resolves connection options from connection and credential parameters.

  • correlationId (optional) transaction id to trace execution through call chain. Return resolved options.

Implementation

Future<ConfigParams> resolve(String? correlationId) async {
  var connections = <ConnectionParams>[];
  var credential = CredentialParams();

  await Future(() async {
    connections = await _connectionResolver.resolveAll(correlationId);
    connections = connections.isNotEmpty ? connections : [];

    // Validate if cluster (multiple connections) is supported
    if (connections.isEmpty && !_clusterSupported) {
      throw ConfigException(
          correlationId,
          'MULTIPLE_CONNECTIONS_NOT_SUPPORTED',
          'Multiple (cluster) connections are not supported');
    }

    for (dynamic connection in connections) {
      validateConnection(correlationId, connection);
    }
  });

  await Future(() async {
    var result = await _credentialResolver.lookup(correlationId);
    credential = result ?? credential;
    // Validate credential
    validateCredential(correlationId, credential);
  });

  return composeOptions(connections, credential, _options!);
}