@resonatehq/sdk
    Preparing search index...

    Class Resonate

    Index

    Constructors

    • Creates a new Resonate client instance.

      Parameters

      • options: {
            encryptor?: Encryptor;
            group?: string;
            logger?: Logger;
            logLevel?: LogLevel;
            network?: Network;
            pid?: string;
            prefix?: string;
            timeout?: number;
            token?: string;
            ttl?: number;
            url?: string;
            verbose?: boolean;
        } = {}

        Configuration options for the client.

        • Optionalencryptor?: Encryptor

          Payload encryptor. Defaults to NoopEncryptor.

        • Optionalgroup?: string

          Worker group name. Defaults to "default".

        • Optionallogger?: Logger

          Custom logger implementation. Defaults to ConsoleLogger.

        • OptionallogLevel?: LogLevel

          Log level for the default ConsoleLogger. Defaults to "warn". Takes precedence over verbose.

        • Optionalnetwork?: Network

          Custom network implementation. Defaults to undefined.

        • Optionalpid?: string

          Process identifier for the client. Defaults to a random UUID.

        • Optionalprefix?: string

          ID prefix applied to generated IDs. Defaults to process.env.RESONATE_PREFIX when set.

        • Optionaltimeout?: number

          Network request timeout. Passed through to HttpNetwork which falls back to RESONATE_TIMEOUT env var (default: 10s).

        • Optionaltoken?: string

          Bearer token for authentication. Passed through to HttpNetwork which falls back to RESONATE_TOKEN env var.

        • Optionalttl?: number

          Time-to-live (in seconds) for claimed tasks. Defaults to 1 * util.MIN.

        • Optionalurl?: string

          Resonate server URL. Falls back to process.env.RESONATE_URL. If no URL is resolved, a local in-memory network is used.

        • Optionalverbose?: boolean

          Enables verbose logging (shorthand for logLevel: "debug"). Defaults to false.

      Returns Resonate

    Properties

    promises: Promises
    schedules: Schedules

    Methods

    • Builds a resolved Options object by merging the provided partial options with the client's defaults.

      This is useful for inspecting the effective configuration that would be applied to a run, rpc, or schedule call, or for passing explicit options to the convenience methods on a ResonateFunc handle.

      Parameters

      • opts: Partial<
            Pick<Options, "tags" | "target" | "timeout" | "version" | "retryPolicy">,
        > = {}

        Partial options to merge. Supports tags, target, timeout, version, and retryPolicy.

      Returns Options

      A fully resolved Options object.

    • Registers a function with Resonate for execution and version control.

      Type Parameters

      Parameters

      • name: string
      • func: F
      • Optionaloptions: { version?: number }

      Returns ResonateFunc<F>

    • Registers a function with Resonate for execution and version control.

      Type Parameters

      Parameters

      • func: F
      • Optionaloptions: { version?: number }

      Returns ResonateFunc<F>

    • Type Parameters

      Parameters

      • id: string
      • func: F
      • ...args: [...Params<F>[], Options?]

      Returns Promise<Return<F>>

    • Type Parameters

      • T

      Parameters

      • id: string
      • name: string
      • ...args: any[]

      Returns Promise<T>

    • Type Parameters

      • T

      Parameters

      • id: string
      • funcOrName: string | Func
      • ...args: any[]

      Returns Promise<T>

    • Type Parameters

      Parameters

      • id: string
      • func: F
      • ...args: [...Params<F>[], Options?]

      Returns Promise<Return<F>>

    • Type Parameters

      • T

      Parameters

      • id: string
      • name: string
      • ...args: any[]

      Returns Promise<T>

    • Type Parameters

      • T

      Parameters

      • id: string
      • funcOrName: string | Func
      • ...args: any[]

      Returns Promise<T>

    • Creates a recurring schedule that invokes a registered function on a cron interval.

      The schedule is persisted on the Resonate Server and triggers a new durable promise for each cron tick. The generated promise IDs include the schedule name and timestamp to ensure uniqueness across invocations.

      If a function reference is provided, it must already be registered via register. Alternatively, a function name (string) can be used for remote dispatch.

      Type Parameters

      Parameters

      • name: string

        A unique name identifying this schedule.

      • cron: string

        A cron expression defining the recurrence interval (e.g., "* * * * *" for every minute).

      • func: F
      • ...args: [...Params<F>[], Options?]

        Positional arguments and optional configuration parameters passed to the function.

      Returns Promise<ResonateSchedule>

      A ResonateSchedule handle with a delete() method to remove the schedule.

      const schedule = await resonate.schedule("daily-report", "0 0 * * *", generateReport);
      // Later, to remove:
      await schedule.delete();
    • Creates a recurring schedule that invokes a registered function on a cron interval.

      The schedule is persisted on the Resonate Server and triggers a new durable promise for each cron tick. The generated promise IDs include the schedule name and timestamp to ensure uniqueness across invocations.

      If a function reference is provided, it must already be registered via register. Alternatively, a function name (string) can be used for remote dispatch.

      Parameters

      • name: string

        A unique name identifying this schedule.

      • cron: string

        A cron expression defining the recurrence interval (e.g., "* * * * *" for every minute).

      • func: string
      • ...args: any[]

        Positional arguments and optional configuration parameters passed to the function.

      Returns Promise<ResonateSchedule>

      A ResonateSchedule handle with a delete() method to remove the schedule.

      const schedule = await resonate.schedule("daily-report", "0 0 * * *", generateReport);
      // Later, to remove:
      await schedule.delete();
    • Registers a named dependency that will be available to all Resonate functions via context.getDependency(name).

      Use this to inject services, clients, or configuration objects into Resonate functions without tight coupling.

      Parameters

      • name: string

        A unique key identifying the dependency.

      • obj: any

        The dependency value (any object or primitive).

      Returns void

    • Stops the Resonate client, releasing all resources.

      This shuts down the underlying network transport and message source, stops the heartbeat loop, and clears the subscription refresh interval. After calling stop(), the client should not be used for further operations.

      Returns Promise<void>