Skip to main content

Classes & Interfaces

QueueClient

interface QueueClient
Represents a request queue with methods for submitting requests, checking their status, retrieving results, and subscribing to updates.

Methods

submit

submit(endpointId: Id, options: SubmitOptions<InputType<Id>>): Promise<InQueueQueueStatus>
Submits a request to the queue.
ParameterTypeDescription
endpointIdId- The ID of the function web endpoint.
optionsSubmitOptions<InputType<Id>>- Options to configure how the request is run.
Returns: Promise<InQueueQueueStatus>

status

status(endpointId: string, options: QueueStatusOptions): Promise<QueueStatus>
Retrieves the status of a specific request in the queue.
ParameterTypeDescription
endpointIdstring- The ID of the function web endpoint.
optionsQueueStatusOptions- Options to configure how the request is run.
Returns: Promise<QueueStatus>

streamStatus

streamStatus(endpointId: string, options: QueueStatusStreamOptions): Promise<FalStream<unknown, QueueStatus>>
Subscribes to updates for a specific request in the queue using HTTP streaming events.
ParameterTypeDescription
endpointIdstring- The ID of the function web endpoint.
optionsQueueStatusStreamOptions- Options to configure how the request is run and how updates are received.
Returns: Promise<FalStream<unknown, QueueStatus>>

subscribeToStatus

subscribeToStatus(endpointId: string, options: QueueStatusSubscriptionOptions): Promise<CompletedQueueStatus>
Subscribes to updates for a specific request in the queue using polling or streaming. See options.mode for more details.
ParameterTypeDescription
endpointIdstring- The ID of the function web endpoint.
optionsQueueStatusSubscriptionOptions- Options to configure how the request is run and how updates are received.
Returns: Promise<CompletedQueueStatus>

result

result(endpointId: Id, options: BaseQueueOptions): Promise<Result<OutputType<Id>>>
Retrieves the result of a specific request from the queue.
ParameterTypeDescription
endpointIdId- The ID of the function web endpoint.
optionsBaseQueueOptions- Options to configure how the request is run.
Returns: Promise<Result<OutputType<Id>>>

cancel

cancel(endpointId: string, options: BaseQueueOptions): Promise<void>
Cancels a request in the queue.
ParameterTypeDescription
endpointIdstring- The ID of the function web endpoint.
optionsBaseQueueOptions- Options to configure how the request is run and how updates are received.
Returns: Promise<void>

Types

QueuePriority

type QueuePriority = "low" | "normal"

QueueStatusSubscriptionOptions

type QueueStatusSubscriptionOptions = QueueStatusOptions &
  QueueModeOptions &
  Omit<QueueCommonSubscribeOptions, "onEnqueue" | "webhookUrl">

QueueSubscribeOptions

type QueueSubscribeOptions = QueueCommonSubscribeOptions &
  QueueModeOptions
Options for subscribing to the request queue.

SubmitOptions

type SubmitOptions = RunOptions<Input> & {
  /**
   * The URL to send a webhook notification to when the request is completed.
   * @see WebHookResponse
   */
  webhookUrl?: string;

  /**
   * The priority of the request. It defaults to `normal`.
   * This will be sent as the `x-fal-queue-priority` header.
   *
   * @see QueuePriority
   */
  priority?: QueuePriority;

  /**
   * A hint for the runner to use when processing the request.
   * This will be sent as the `x-fal-runner-hint` header.
   */
  hint?: string;

  /**
   * Additional HTTP headers to include in the submit request.
   *
   * Note: `priority`, `hint`, and `objectLifecycle` will override the following headers:
   *  - `x-fal-queue-priority`
   *  - `x-fal-runner-hint`
   *  - `x-fal-object-lifecycle-preference`
   */
  headers?: Record<string, string>;
}
Options for submitting a request to the queue.

QueueStatusOptions

type QueueStatusOptions = BaseQueueOptions & {
  /**
   * If `true`, the response will include the logs for the request.
   * Defaults to `false`.
   */
  logs?: boolean;
}

QueueStatusStreamOptions

type QueueStatusStreamOptions = QueueStatusOptions & {
  /**
   * The connection mode to use for streaming updates. It defaults to `server`.
   * Set to `client` if your server proxy doesn't support streaming.
   */
  connectionMode?: StreamingConnectionMode;
}