close method

  1. @override
Future close(
  1. String? correlationId
)

Closes component and frees used resources.

  • correlationId (optional) transaction id to trace execution through call chain. Return Future that receives null no errors occured. Throws error

Implementation

@override
Future close(String? correlationId) async {
  if (connection == null) {
    return null;
  }
  try {
    await connection!.close();
    connection = null;
    databaseName = null;
    logger.debug(correlationId, 'Disconnected from mongodb database %s',
        [databaseName]);
  } catch (err) {
    throw ConnectionException(correlationId, 'DISCONNECT_FAILED',
            'Disconnect from mongodb failed: ')
        .withCause(err);
  }
}