Skip to main content

Python client SDK for the Fila message broker

Project description

fila-python

Python client SDK for the Fila message broker.

Installation

pip install fila-python

Usage (Sync)

from fila import Client

client = Client("localhost:5555")

# Enqueue a message.
msg_id = client.enqueue("my-queue", {"tenant": "acme"}, b"hello world")
print(f"Enqueued: {msg_id}")

# Consume messages.
for msg in client.consume("my-queue"):
    print(f"Received: {msg.id} (attempt {msg.attempt_count})")

    # Acknowledge successful processing.
    client.ack("my-queue", msg.id)

client.close()

Usage (Async)

import asyncio
from fila import AsyncClient

async def main():
    async with AsyncClient("localhost:5555") as client:
        msg_id = await client.enqueue("my-queue", {"tenant": "acme"}, b"hello")

        async for msg in await client.consume("my-queue"):
            print(f"Received: {msg.id}")
            await client.ack("my-queue", msg.id)

asyncio.run(main())

API

Client(addr) / AsyncClient(addr)

Connect to a Fila broker. Both support context manager protocol.

client.enqueue(queue, headers, payload) -> str

Enqueue a message. Returns the broker-assigned message ID.

client.consume(queue) -> Iterator[ConsumeMessage]

Open a streaming consumer. Returns an iterator (sync) or async iterator (async) that yields messages as they become available.

client.ack(queue, msg_id)

Acknowledge a successfully processed message. The message is permanently removed.

client.nack(queue, msg_id, error)

Negatively acknowledge a failed message. The message is requeued or routed to the dead-letter queue based on the queue's configuration.

Error Handling

Per-operation exception classes:

from fila import QueueNotFoundError, MessageNotFoundError

try:
    client.enqueue("missing-queue", None, b"test")
except QueueNotFoundError:
    print("Queue does not exist")

try:
    client.ack("my-queue", "missing-id")
except MessageNotFoundError:
    print("Message does not exist")

License

AGPLv3

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

fila_python-0.1.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

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

fila_python-0.1.0-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file fila_python-0.1.0.tar.gz.

File metadata

  • Download URL: fila_python-0.1.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fila_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ce53634592178dc2061fe184fa2ebf0e0820fdf0854a953d80c65d053aab365d
MD5 bfcd774fd219e10dab2cb1fc03cfbf4f
BLAKE2b-256 cfb9caec8d4788a2fadeca797a179ea83b1ea45cf84b0d6822d66135e93ec055

See more details on using hashes here.

Provenance

The following attestation bundles were made for fila_python-0.1.0.tar.gz:

Publisher: publish.yml on faiscadev/fila-python

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

File details

Details for the file fila_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fila_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fila_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f838c1e599a2f3a99ea4f336a6d27a0bdda45db38d9d92e1c801d8a52115282
MD5 0ecfc5db7bf9e21e18d72ea8d3f2c8a2
BLAKE2b-256 40322be12cf2d7f995ec934664b51d3a19e3090af100cb10db09c0669abf47bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fila_python-0.1.0-py3-none-any.whl:

Publisher: publish.yml on faiscadev/fila-python

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