UNPKG

1.04 kBTypeScriptView Raw
1/** @module run */
2/**
3 * Interface for components that require explicit closure.
4 *
5 * For components that require opening as well as closing
6 * use [[IOpenable]] interface instead.
7 *
8 * @see [[IOpenable]]
9 * @see [[Closer]]
10 *
11 * ### Example ###
12 *
13 * class MyConnector implements ICloseable {
14 * private _client: any = null;
15 *
16 * ... // The _client can be lazy created
17 *
18 * public close(correlationId: string, callback: (err: any) => void): void {
19 * if (this._client != null) {
20 * this._client.close();
21 * this._client = null;
22 * }
23 * callback(null);
24 * }
25 * }
26 *
27 */
28export interface IClosable {
29 /**
30 * Closes component and frees used resources.
31 *
32 * @param correlationId (optional) transaction id to trace execution through call chain.
33 * @param callback callback function that receives error or null no errors occured.
34 */
35 close(correlationId: string, callback?: (err: any) => void): void;
36}