Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.87 KB

File metadata and controls

50 lines (38 loc) · 1.87 KB

QueueFlow Python facade

This package ships an ergonomic facade (queueflow.facade) layered over the generated client. It is the recommended entry point. The generated queueflow.api.* clients and queueflow.models.* remain available for advanced use.

Quick start

from queueflow.facade import QueueFlow, wf

qf = QueueFlow("http://localhost:8000", "dev")

# Enqueue a job and wait for the result.
job = qf.create_job("echo", payload={"hello": "world"}, max_retries=3)
done = qf.wait_for_job(job.id)
print(done.status, done.result)

# Declare and run a DAG workflow.
dag = (
    wf("etl")
    .step("extract", "echo")
    .step("transform", "echo", after=["extract"])
    .step("load", "echo", after=["transform"])
)
workflow = qf.create_workflow(dag)
finished = qf.wait_for_workflow(workflow.id)
print(finished.status, finished.context)

API

QueueFlow(base_url, token) exposes:

  • .jobs / .workflows / .worker / .cron / .dlq / .system — the generated api clients, for anything the helpers below do not cover.
  • .create_job(task, payload=None, priority=None, max_retries=None, timeout=None, queue=None, idempotency_key=None) -> Job
  • .wait_for_job(job_id, timeout=60.0, interval=0.5) -> Job
  • .create_workflow(builder_or_request) -> Workflow
  • .wait_for_workflow(workflow_id, timeout=60.0, interval=0.5) -> Workflow

wf(name) / WorkflowBuilder build a DAG; .build() validates locally (duplicate names, dangling dependencies, cycles) and raises WorkflowValidationError before any network round-trip. wait_for_* raise WaitTimeout past their deadline.

How this package is built

The facade is injected at generation time from the queueflow-core-rs template (sdk-templates/python/facade.mustache), so it is regenerated alongside the generated core and can never drift from the server. Do not edit queueflow/facade.py directly; edit the template.