Classes

@system-inc/base-foundation · 515c140 · 4 symbols

Base class for messages that are persisted before being queued. Orm (Drizzle) counterpart of PersistedMessageEntity: the row tracks the message's processing status across the queue lifecycle. Extend it with the message's specific data.

extends OrmMutableBaseEntity

Members

  • createdAt: Date

  • id: string

  • status: PersistentMessageStatus

  • statusChangedAt: Date | null

    The time at which the status was last changed.

  • statusMeta: object | null

    Metadata specifically related to the current status of the job.

  • updatedAt: Date

  • hasBeenUpdated: boolean

    Whether this row has been updated since it was created.

    updatedAt is initialized to the same instant as createdAt on insert, then bumped on every update — so the row has never been updated exactly when updatedAt === createdAt. (This replaces the old "updatedAt is null" sentinel, which couldn't work on backends where the column is NOT NULL.)

  • clone(): T

  • getChangedFields(): OrmPartialEntity<this>

  • toJSON(options?: { strict?: boolean }): Dictionary<unknown>

  • updateStatus(status: PersistentMessageStatus, statusMeta?: object): void

    Update the status of the job.

  • static from(this: () => T, data: OrmPartialEntity<T>): T

    Create a new instance of the entity with the given data.

View source ↗

A WorkerQueue is a queue that can be used to submit messages processing by a different consuming worker. This allows you to offload work to a different worker to be processed after the current worker has finished handling the request.

Members

View source ↗

Binding for a Cloudflare Queue producer. The name matches the binding declared in wrangler.toml. Used with @InjectWorkerQueue(...).

The MessageType parameter is the type of message the queue accepts; the decorator return type threads it through as WorkerQueue<MessageType>.

extends TypedBinding

Members

  • name: string

  • toString(): string

View source ↗

Provides context about the queue message being processed.

Members

  • container: BaseInjectionContainer

  • attempts: number

    The number of times the message has been attempted to be processed.

  • id: string

    The unique identifier for the message on the queue.

  • timestamp: Date

    The timestamp when the message was received by the queue.

  • type: string

    The type of the message.

  • acknowledge(): void

    Acknowledge the message, indicating that it has been processed successfully.

  • getMessage(): MessageType

    Get the payload of the message as a specific type.

  • retry(options?: any): void

    Retry the message, indicating that it should be reprocessed.

View source ↗