Interface Base<Type, Data, CustomHeaders, CustomOptions>

A resource is extended component that represent the access to an external/internal resource, besides the error handling and identity, it has a start, stop and close methods to manage the resource lifecycle. It also has a checks property to define the checks that will be performed over the resource to achieve the resulted status. The most typical example of a resource are the Provider that allow to access to external databases, message brokers, etc.

interface Base<
    Type extends string = string,
    Data = any,
    CustomHeaders extends Record<string, any> = NoMoreHeaders,
    CustomOptions extends Record<string, any> = NoMoreOptions,
> {
    metrics?: Registry<"text/plain; version=0.0.4; charset=utf-8">;
    single: (
        job: JobObject<Type, Data, CustomHeaders, CustomOptions>,
    ) => Promise<void>;
    on(event: "error", listener: (error: Crash | Error) => void): this;
    on(
        event: "status",
        listener: (status: "pass" | "fail" | "warn") => void,
    ): this;
    start(): Promise<void>;
    stop(): Promise<void>;
}

Type Parameters

  • Type extends string = string
  • Data = any
  • CustomHeaders extends Record<string, any> = NoMoreHeaders
  • CustomOptions extends Record<string, any> = NoMoreOptions

Hierarchy (View Summary)

Properties

Methods

Properties

metrics?: Registry<"text/plain; version=0.0.4; charset=utf-8">

Metrics registry for this component

single: (
    job: JobObject<Type, Data, CustomHeaders, CustomOptions>,
) => Promise<void>

Perform the processing of a single Job

Type declaration

Methods

  • Emitted when the component throw an error

    Parameters

    • event: "error"
    • listener: (error: Crash | Error) => void

    Returns this

  • Emitted on every status change

    Parameters

    • event: "status"
    • listener: (status: "pass" | "fail" | "warn") => void

    Returns this

  • Start the Plug and the underlayer resources, making it available

    Returns Promise<void>

  • Stop the Plug and the underlayer resources, making it unavailable

    Returns Promise<void>