FalEx.Queue (fal_ex v0.1.0)
View SourceQueue client for managing asynchronous fal.ai requests.
Provides functionality to submit jobs to the queue, monitor their status, and retrieve results when complete.
Summary
Functions
Cancels a queued request.
Creates a new queue client.
Gets the result of a completed request.
Gets the status of a queued request.
Submits a request to the queue.
Subscribes to status updates for a queued request.
Types
@type t() :: %FalEx.Queue{config: FalEx.Config.t()}
Functions
@spec cancel(t(), FalEx.Types.endpoint_id(), keyword()) :: :ok | {:error, term()}
Cancels a queued request.
Creates a new queue client.
@spec result(t(), FalEx.Types.endpoint_id(), keyword()) :: {:ok, FalEx.Types.result()} | {:error, term()}
Gets the result of a completed request.
@spec status(t(), FalEx.Types.endpoint_id(), keyword()) :: {:ok, FalEx.Types.queue_status_response()} | {:error, term()}
Gets the status of a queued request.
Options
:request_id
- The request ID to check:logs
- Include execution logs (default: false)
@spec submit(t(), FalEx.Types.endpoint_id(), keyword()) :: {:ok, map()} | {:error, term()}
Submits a request to the queue.
Options
:input
- The input payload for the model:webhook_url
- Optional webhook URL for completion notification
Examples
{:ok, %{"request_id" => request_id}} = Queue.submit(queue, "fal-ai/fast-sdxl",
input: %{prompt: "A cat"}
)
@spec subscribe_to_status(t(), FalEx.Types.endpoint_id(), keyword()) :: :ok | {:error, term()}
Subscribes to status updates for a queued request.
Polls or uses SSE to monitor the request status until completion.
Options
:request_id
- The request ID to monitor:logs
- Include logs in status updates:on_queue_update
- Callback function for status updates:poll_interval
- Polling interval in ms (default: 500):timeout
- Maximum time to wait in ms (default: 300000)