resolve method

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

Resolves MongoDB connection URI from connection and credential parameters.

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

Implementation

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

  Future<dynamic> Function() resolv = () async {
    connections = await connectionResolver.resolveAll(correlationId);
    // Validate connections
    var err = _validateConnections(correlationId, connections);
    if (err != null) {
      throw err;
    }
  };

  Future<dynamic> Function() lookup = () async {
    credential = await credentialResolver.lookup(correlationId);
    // Credentials are not validated right now
  };

  return await Future.wait([resolv(), lookup()]).then((list) {
    return _composeUri(connections, credential);
  });
}