Type Parameters

  • T

Constructors

  • Creates a Durable Promise instance. This is provided as a lower level API, used by the Resonate class internally.

    Type Parameters

    • T

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • promise: DurablePromiseRecord

      The raw Durable Promise.

    Returns DurablePromise<T>

Properties

complete: ((value) => void)

Type declaration

completed: Promise<DurablePromise<T>>
encoder: IEncoder<unknown, undefined | string>

An encoder instance used for encode and decode promise data.

interval: undefined | Timeout
promise: DurablePromiseRecord

The raw Durable Promise.

A reference to a promise store.

Accessors

  • get idempotencyKeyForComplete(): undefined | string
  • The Durable Promise complete idempotency key.

    Returns undefined | string

  • get idempotencyKeyForCreate(): undefined | string
  • The Durable Promise create idempotency key.

    Returns undefined | string

Methods

  • Polls the Durable Promise store to sychronize the state, stops when the promise is complete.

    Parameters

    • timeout: number = Infinity

      The time at which to stop polling if the promise is still pending.

    • frequency: number = 5000

      The frequency in ms to poll.

    Returns Promise<void>

    A Promise that resolves when the Durable Promise is complete.

  • Polls the Durable Promise store, and returns the value when the Durable Promise is complete.

    Parameters

    • timeout: number = Infinity

      The time at which to stop polling if the promise is still pending.

    • frequency: number = 5000

      The frequency in ms to poll.

    Returns Promise<T>

    The promise value, or throws an error.

  • Cancels a Durable Promise.

    Type Parameters

    • T

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • id: string

      The Durable Promise id.

    • error: any

      The Durable Promise error value, will be encoded with the provided encoder.

    • opts: Partial<CompleteOptions> = {}

      A partial Durable Promise create options.

    Returns Promise<DurablePromise<T>>

    A Durable Promise instance.

  • Creates a Durable Promise.

    Type Parameters

    • T

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • id: string

      The Durable Promise id.

    • timeout: number

      The Durable Promise timeout in milliseconds.

    • opts: Partial<CreateOptions> = {}

      A partial Durable Promise create options.

    Returns Promise<DurablePromise<T>>

    A Durable Promise instance.

  • Rejects a Durable Promise.

    Type Parameters

    • T

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • id: string

      The Durable Promise id.

    • error: any

      The Durable Promise error value, will be encoded with the provided encoder.

    • opts: Partial<CompleteOptions> = {}

      A partial Durable Promise create options.

    Returns Promise<DurablePromise<T>>

    A Durable Promise instance.

  • Resolves a Durable Promise.

    Type Parameters

    • T

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • id: string

      The Durable Promise id.

    • value: T

      The Durable Promise value, will be encoded with the provided encoder.

    • opts: Partial<CompleteOptions> = {}

      A partial Durable Promise create options.

    Returns Promise<DurablePromise<T>>

    A Durable Promise instance.

  • Search for Durable Promises.

    Parameters

    • store: IPromiseStore

      A reference to a promise store.

    • encoder: IEncoder<unknown, undefined | string>

      An encoder instance used for encode and decode promise data.

    • id: string

      An id to match against Durable Promise ids, can include wilcards.

    • Optional state: string

      A state to search for, can be one of {pending, resolved, rejected}, matches all states if undefined.

    • Optional tags: Record<string, string>

      Tags to search against.

    • Optional limit: number

      The maximum number of Durable Promises to return per page.

    Returns AsyncGenerator<DurablePromise<any>[], void, unknown>

    An async generator that yields Durable Promise instances.