IClosable

Interface that allows you to create a component with a method that closes it and frees used resources.

Description

The IClosable interface allows you to create a component with a method that closes it and frees used resources.

Instance methods

close

Closes a component and frees used resources.

close(context: IContext): Promise<void>

  • context: IContext - (optional) execution context to trace execution through call chain.

Examples

		type MyConnector {
			_client interface{}
		}
		... // The _client can be lazy created
		func (mc *MyConnector) Close(ctx context.Context) error {
			if (mc._client != nil) {
				mc._client.Close(ctx)
				mc._client = nil
				return nil
			}
		}

See also