open method
Implementation
Future<void> open(WriteConcern writeConcern) async {
var connectionErrors = [];
for (var hostUrl in _connectionPool.keys) {
var connection = _connectionPool[hostUrl];
if (connection == null) {
connectionErrors
.add('Connection in pool for server "$hostUrl" has not been found');
continue;
}
try {
await _connect(connection);
} catch (e) {
connectionErrors.add(e);
}
}
if (connectionErrors.isNotEmpty) {
if (_masterConnection == null) {
for (var error in connectionErrors) {
_log.severe('$error');
}
// Simply returns the first exception to be more compatible
// with previous error management.
throw connectionErrors.first;
} else {
for (var error in connectionErrors) {
_log.warning('$error');
}
}
}
if (_masterConnection == null) {
throw MongoDartError('No Primary found');
}
if (unfilled(db.databaseName)) {
throw MongoDartError('Database name not specified');
}
db.state = State.open;
if (_masterConnection!.serverCapabilities.supportsOpMsg) {
await ServerStatusCommand(db,
serverStatusOptions: ServerStatusOptions.instance)
.updateServerStatus(db.masterConnection);
}
}