Skip to main content

Async, typed Python runtime client for FlowQueue (publish + consume)

Project description

flowqueue

Async, typed Python runtime client for FlowQueue — a cloud-native message processing platform. The SDK does two things: publish messages and consume deliveries. Everything else (creating queues/consumers, API keys, replay, dead-letter recovery, metrics) lives in the FlowQueue UI (or the HTTP API directly).

pip install flowqueue

Requires Python 3.9+. Ships with type hints (py.typed) — editors autocomplete response shapes (MessageOut, DeliveryOut).

Quickstart

Create the queue and consumer in the FlowQueue UI, then use their ids here:

import asyncio
from flowqueue import AsyncFlowQueueClient, AsyncFlowQueueConsumer

QUEUE_ID = "<queue_id>"
CONSUMER_ID = "<consumer_id>"


async def main():
    async with AsyncFlowQueueClient("https://flowqueue.example.com", "fq_your_api_key") as client:
        # Publish (optionally scheduled)
        await client.publish(QUEUE_ID, {"order_id": 42}, idempotency_key="order-42")
        await client.publish(QUEUE_ID, {"order_id": 43}, delay_seconds=30)  # deliver in 30s

        # Consume one delivery
        consumer = AsyncFlowQueueConsumer(client, CONSUMER_ID)
        d = await consumer.poll()
        if d:
            print(d["payload"])
            await consumer.complete(d["id"], remark="done")


asyncio.run(main())

Run a worker loop

The handler may be sync or async. Return → the delivery is completed; raise → it is failed (retry / DLQ per queue config).

async def handle(delivery):
    await process(delivery["payload"])

async def main():
    async with AsyncFlowQueueClient(url, key) as client:
        await AsyncFlowQueueConsumer(client, CONSUMER_ID).run(handle, poll_interval=2.0)

Scheduling

from datetime import datetime, timedelta, timezone

await client.publish(qid, {"ping": 1}, delay_seconds=30)
await client.publish(qid, {"ping": 1}, deliver_at=datetime.now(timezone.utc) + timedelta(hours=1))

Errors

Non-2xx responses raise flowqueue.ApiError(status, code, message).

from flowqueue import ApiError

try:
    await client.publish(qid, {"x": 1})
except ApiError as e:
    print(e.status, e.code, e.message)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flowqueue-0.2.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flowqueue-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file flowqueue-0.2.0.tar.gz.

File metadata

  • Download URL: flowqueue-0.2.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flowqueue-0.2.0.tar.gz
Algorithm Hash digest
SHA256 66b849f2c0a8d4aac4fe7bd0bc9ffccbc4dcc252eb2365831357e1f11aea0507
MD5 c1f9eb31c89d82a56b2e2f34b0d4110f
BLAKE2b-256 4534e2cc524a0c3dfec799c6a5542304dda5a7db2ac9d99f53e6829ac5279a30

See more details on using hashes here.

Provenance

The following attestation bundles were made for flowqueue-0.2.0.tar.gz:

Publisher: publish.yml on Skill-College/flowqueue

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flowqueue-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: flowqueue-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flowqueue-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95517ce78e5aa79ded245e4ba8efa38316ef4bd4c539e0344281cc5453db9999
MD5 d06f7e5af5c607268babc54463a7c1c2
BLAKE2b-256 72acc6a3b40709a98aef0bc710f6dcdc16c0f4e5d83da9182aeb71e029c8648c

See more details on using hashes here.

Provenance

The following attestation bundles were made for flowqueue-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Skill-College/flowqueue

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page