pip-services3-commons-node
Version:
Portable abstractions and patterns for Pip.Services in Node.js
37 lines (36 loc) • 1.04 kB
TypeScript
/** @module run */
/**
* Interface for components that require explicit closure.
*
* For components that require opening as well as closing
* use [[IOpenable]] interface instead.
*
* @see [[IOpenable]]
* @see [[Closer]]
*
* ### Example ###
*
* class MyConnector implements ICloseable {
* private _client: any = null;
*
* ... // The _client can be lazy created
*
* public close(correlationId: string, callback: (err: any) => void): void {
* if (this._client != null) {
* this._client.close();
* this._client = null;
* }
* callback(null);
* }
* }
*
*/
export interface IClosable {
/**
* Closes component and frees used resources.
*
* @param correlationId (optional) transaction id to trace execution through call chain.
* @param callback callback function that receives error or null no errors occured.
*/
close(correlationId: string, callback?: (err: any) => void): void;
}