tedious
Version:
A TDS driver, for connecting to MS SQLServer databases.
62 lines (61 loc) • 2.44 kB
TypeScript
/**
* Options of a single execution of a {@link Request} or {@link BulkLoad}.
*
* @experimental
*/
export interface ExecutionOptions {
/**
* Cancels the execution when aborted. The execution then completes with a
* {@link RequestError} whose `code` is `'ABORT_ERR'`, whose `name` is
* `'AbortError'`, and whose `cause` is the signal's `reason`, instead of a
* cancellation error.
*
* If the signal is aborted already, the request is not sent at all.
*
* If the execution was canceled otherwise before the signal was aborted,
* via `cancel()` or by a request timeout, it completes with that
* cancellation's error instead. If the server does not acknowledge the
* cancellation within {@link ConnectionOptions.cancelTimeout}, the
* connection is closed and the execution fails with that connection error.
*
* As with `cancel()`, an error that the execution ran into before it was
* canceled, e.g. an error returned by the server or a parameter value that
* failed to stream, is either reported or replaced by the abort error,
* depending on how far the execution got.
*/
signal?: AbortSignal | undefined;
}
/**
* A request or bulk load, as far as its cancellation is concerned.
*
* @private
*/
interface Execution {
canceled: boolean;
callback: (error: Error | null | undefined, ...rest: any[]) => void;
cancel(): void;
}
/**
* The given request's or bulk load's callback, without the replacements
* {@link abortOnSignal} made for the executions that are in progress.
*
* An execution that is rejected while another execution of the same request
* or bulk load is in progress must call back with this callback. Otherwise,
* its completion would be taken for the completion of the execution in
* progress, whose signal would no longer be listened to.
*
* @private
*/
export declare function originalCallback(execution: Execution): Execution['callback'];
/**
* Cancel the current execution of the given request or bulk load once the
* signal is aborted, and let it complete with an abort error instead of the
* cancellation error.
*
* The execution's `callback` is replaced until the execution completed, so
* this must only be called once the execution is certain to call back.
*
* @private
*/
export declare function abortOnSignal(execution: Execution, signal: AbortSignal | undefined): void;
export {};