close method
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
Implementation
@override
Future close(String? correlationId) async {
// Skip if container wasn't opened
if (references == null) {
return null;
}
try {
logger.trace(correlationId, 'Stopping %s container', [info?.name]);
// Unset references for child container
unsetReferences();
// Close and dereference components
try {
await references!.close(correlationId);
} catch (err) {
references = null;
logger.info(correlationId, 'Container %s stopped', [info?.name]);
return null;
}
} catch (ex) {
logger.error(correlationId, ex as Exception, 'Failed to stop container');
rethrow;
}
}