@bitsinfra/fusee
    Preparing search index...

    Class ObjectCtx

    The context of an object's handler: the workflow context of the key's run, its state and its key.

    Hierarchy (View Summary)

    Index
    exclusive: boolean

    Whether this handler is exclusive (it may change state).

    The key's state.

    • get objectKey(): string

      The object's key.

      Returns string

    • get runId(): number

      Returns number

    • get version(): number

      Returns number

    • get workflowId(): string

      Returns string

    • get workflowType(): string

      Returns string

    • Like Promise.all, for journal operations.

      Type Parameters

      • T extends readonly unknown[]

      Parameters

      • ops: T

      Returns Promise<{ -readonly [K in string | number | symbol]: Awaited<T[K]> }>

    • A step completed from outside: send(token) starts work elsewhere and returns; the workflow waits until a process holding the token calls engine.complete(token, value) or engine.fail(token, error). send is retried under the retry policy, each attempt with a new token.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • Asks another workflow to cancel, once this point is durable.

      Parameters

      • target: string
      • reason: string = "cancelled"

      Returns void

    • Registers a step that undoes what the workflow did so far: if the workflow fails or is cancelled, every registered compensation runs as a step named name, newest first, then the failure is thrown. Register it after the step it undoes succeeded:

      const hold = await ctx.step("reserve", () => inventory.reserve(sku));
      ctx.compensate("release", () => inventory.release(hold));
      

      Parameters

      Returns void

    • Ends this run and starts a new run of the same ID with input, in one record. Never resolves.

      Type Parameters

      • I

      Parameters

      • input: I
      • opts: { version?: number } = {}

      Returns Promise<never>

    • Marks a patch whose old branch was removed.

      Parameters

      • id: string

      Returns void

    • Progress of the running step. Coalesced; never waits for the disk.

      Type Parameters

      • T

      Parameters

      • progress: T

      Returns void

    • Journal operations this run made so far (deterministic).

      Returns number

    • A key stable across retries and recovery for the step whose function is running (distinct for each run of a workflow ID, including a reset one). Pass it to services that accept idempotency keys.

      Returns string

    • The current time in Unix ms, recorded.

      Returns number

    • Key key of object type type, called from this workflow or handler: each call is a journal operation, sent through the durable outbox and run exactly once; call resolves with the handler's recorded result.

      Parameters

      • type: string
      • key: string

      Returns ObjectCall

    • Registers a read-only query handler (run.query(name, arg)).

      Type Parameters

      • A
      • R

      Parameters

      • name: string
      • fn: (arg: A) => R

      Returns void

    • Registers an update handler (run.update(name, arg)).

      Type Parameters

      • A
      • R

      Parameters

      Returns void

    • True for new runs, and for running ones the first time they get here after the deploy.

      Parameters

      • id: string

      Returns boolean

    • The latest progress the running step reported, also from before a crash.

      Type Parameters

      • T

      Returns T | undefined

    • Like Promise.race; the winner is the first result delivered, which replay reproduces. The losers are dropped (a dropped wait no longer takes signals).

      Type Parameters

      • T

      Parameters

      • ops: Promise<T>[]

      Returns Promise<T>

    • A random number in [0, 1), recorded.

      Returns number

    • Records search attributes (null removes a key). They are never encrypted.

      Parameters

      • attributes: Record<string, unknown>

      Returns void

    • Sends a signal to another workflow once this run is durable through here.

      Type Parameters

      • T

      Parameters

      Returns void

    • signal under the name every SDK uses.

      Type Parameters

      • T

      Parameters

      Returns void

    • Sleeps durably; the run is parked out of memory while it waits.

      Parameters

      Returns Promise<void>

    • Sleeps durably until at; the run is parked out of memory while it waits.

      Parameters

      • name: string
      • at: number | Date

      Returns Promise<void>

    • Type Parameters

      • I

      Parameters

      Returns void

      Use startChild.

    • Starts a child workflow without waiting for it. By default it is terminated when this workflow closes; parentClose: "abandon" lets it outlive it.

      Type Parameters

      • I

      Parameters

      Returns void

    • Runs fn as a durable step. fn runs only once everything this run recorded before is durable (at once with readOnly); its result is recorded and returned without waiting for the disk. On replay the recorded result is returned and fn does not run.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • Opens the run's stream name for appending (readers follow it with run.stream(name)). In workflow code it opens a stream of the run: its appends are recorded once (a replay appends nothing), and close() or the run's end completes it; steps may append to it too. Inside a step's function it opens a stream of the step, which the step's result completes; an attempt that runs again finds what earlier attempts recorded in recorded() and continues after it.

      Parameters

      • name: string

      Returns StreamWriter

    • A random UUID, recorded.

      Returns string

    • Waits for the next signal name. Resolves undefined on timeout.

      Type Parameters

      • T

      Parameters

      Returns Promise<T | undefined>