@servicenow/sdk - v4.13.3
    Preparing search index...

    Dispatcher is the core API used to dispatch requests.

    interface ComposedDispatcher {
        addListener(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        addListener(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        addListener(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        addListener(eventName: "drain", callback: (origin: URL) => void): this;
        close(callback: () => void): void;
        close(): Promise<void>;
        compose(dispatchers: DispatcherComposeInterceptor[]): ComposedDispatcher;
        compose(...dispatchers: DispatcherComposeInterceptor[]): ComposedDispatcher;
        connect<TOpaque = null>(
            options: ConnectOptions<TOpaque>,
            callback: (err: Error | null, data: ConnectData<TOpaque>) => void,
        ): void;
        connect<TOpaque = null>(
            options: ConnectOptions<TOpaque>,
        ): Promise<ConnectData<TOpaque>>;
        destroy(err: Error | null, callback: () => void): void;
        destroy(callback: () => void): void;
        destroy(err: Error | null): Promise<void>;
        destroy(): Promise<void>;
        dispatch(options: DispatchOptions, handler: DispatchHandler): boolean;
        emit(
            eventName: "connect",
            origin: URL,
            targets: readonly Dispatcher[],
        ): boolean;
        emit(
            eventName: "disconnect",
            origin: URL,
            targets: readonly Dispatcher[],
            error: UndiciError,
        ): boolean;
        emit(
            eventName: "connectionError",
            origin: URL,
            targets: readonly Dispatcher[],
            error: UndiciError,
        ): boolean;
        emit(eventName: "drain", origin: URL): boolean;
        listeners(
            eventName: "connect",
        ): ((origin: URL, targets: readonly Dispatcher[]) => void)[];
        listeners(
            eventName: "disconnect",
        ): (
            (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void
        )[];
        listeners(
            eventName: "connectionError",
        ): (
            (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void
        )[];
        listeners(eventName: "drain"): ((origin: URL) => void)[];
        off(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        off(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        off(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        off(eventName: "drain", callback: (origin: URL) => void): this;
        on(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        on(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        on(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        on(eventName: "drain", callback: (origin: URL) => void): this;
        once(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        once(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        once(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        once(eventName: "drain", callback: (origin: URL) => void): this;
        pipeline<TOpaque = null>(
            options: PipelineOptions<TOpaque>,
            handler: PipelineHandler<TOpaque>,
        ): Duplex;
        prependListener(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        prependListener(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        prependListener(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        prependListener(eventName: "drain", callback: (origin: URL) => void): this;
        prependOnceListener(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        prependOnceListener(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        prependOnceListener(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        prependOnceListener(
            eventName: "drain",
            callback: (origin: URL) => void,
        ): this;
        rawListeners(
            eventName: "connect",
        ): ((origin: URL, targets: readonly Dispatcher[]) => void)[];
        rawListeners(
            eventName: "disconnect",
        ): (
            (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void
        )[];
        rawListeners(
            eventName: "connectionError",
        ): (
            (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void
        )[];
        rawListeners(eventName: "drain"): ((origin: URL) => void)[];
        removeListener(
            eventName: "connect",
            callback: (origin: URL, targets: readonly Dispatcher[]) => void,
        ): this;
        removeListener(
            eventName: "disconnect",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        removeListener(
            eventName: "connectionError",
            callback: (
                origin: URL,
                targets: readonly Dispatcher[],
                error: UndiciError,
            ) => void,
        ): this;
        removeListener(eventName: "drain", callback: (origin: URL) => void): this;
        request<TOpaque = null>(
            options: RequestOptions<TOpaque>,
            callback: (err: Error | null, data: ResponseData<TOpaque>) => void,
        ): void;
        request<TOpaque = null>(
            options: RequestOptions<TOpaque>,
        ): Promise<ResponseData<TOpaque>>;
        stream<TOpaque = null>(
            options: RequestOptions<TOpaque>,
            factory: StreamFactory<TOpaque>,
            callback: (err: Error | null, data: StreamData<TOpaque>) => void,
        ): void;
        stream<TOpaque = null>(
            options: RequestOptions<TOpaque>,
            factory: StreamFactory<TOpaque>,
        ): Promise<StreamData<TOpaque>>;
        upgrade(
            options: UpgradeOptions,
            callback: (err: Error | null, data: UpgradeData) => void,
        ): void;
        upgrade(options: UpgradeOptions): Promise<UpgradeData<null>>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided).

      Parameters

      • callback: () => void

      Returns void

    • Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided).

      Returns Promise<void>

    • Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests.

      Parameters

      • err: Error | null
      • callback: () => void

      Returns void

    • Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests.

      Parameters

      • callback: () => void

      Returns void

    • Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests.

      Parameters

      • err: Error | null

      Returns Promise<void>

    • Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests.

      Returns Promise<void>

    • Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this.

      Parameters

      Returns boolean

    • Parameters

      • eventName: "connect"
      • origin: URL
      • targets: readonly Dispatcher[]

      Returns boolean

    • Parameters

      Returns boolean

    • Parameters

      Returns boolean

    • Parameters

      • eventName: "drain"
      • origin: URL

      Returns boolean

    • Parameters

      • eventName: "connect"

      Returns ((origin: URL, targets: readonly Dispatcher[]) => void)[]

    • Parameters

      • eventName: "disconnect"

      Returns ((origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void)[]

    • Parameters

      • eventName: "connectionError"

      Returns ((origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void)[]

    • Parameters

      • eventName: "drain"

      Returns ((origin: URL) => void)[]

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this

    • Parameters

      • eventName: "connect"

      Returns ((origin: URL, targets: readonly Dispatcher[]) => void)[]

    • Parameters

      • eventName: "disconnect"

      Returns ((origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void)[]

    • Parameters

      • eventName: "connectionError"

      Returns ((origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void)[]

    • Parameters

      • eventName: "drain"

      Returns ((origin: URL) => void)[]

    • Parameters

      • eventName: "connect"
      • callback: (origin: URL, targets: readonly Dispatcher[]) => void

      Returns this

    • Parameters

      • eventName: "disconnect"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "connectionError"
      • callback: (origin: URL, targets: readonly Dispatcher[], error: UndiciError) => void

      Returns this

    • Parameters

      • eventName: "drain"
      • callback: (origin: URL) => void

      Returns this