Skip to main content

poofMQ Python SDK - push/pop queue client with optional client-side encryption

Project description

poofMQ Python SDK

Client for the poofMQ API: push and pop messages with optional client-side AES-GCM encryption (zero-knowledge mode). Uses the OpenAPI-generated client and types as the single source of truth.

Install from PyPI:

pip install poofmq

Usage

Plaintext push and pop

import os

from poofmq import PoofmqClient

base_url = os.environ.get("POOFMQ_BASE_URL")

if base_url is None:
    raise RuntimeError("Set POOFMQ_BASE_URL to the poofMQ API origin.")

client = PoofmqClient(
    base_url=base_url,
    api_key=os.environ.get("POOFMQ_API_KEY"),  # optional
)

# Push
res = client.push("my-queue-id", "user.created", {"user_id": "123"})
print("Message ID:", res.message_id)

# Pop
message = client.pop("my-queue-id")
if message:
    print("Event:", message.envelope.event_type, message.envelope.payload)

POOFMQ_BASE_URL should point to the API origin from the quickstart, not https://poofmq.com.

Client-side encrypted push (zero-knowledge)

res = client.push(
    "my-queue-id",
    "order.placed",
    {"order_id": "ord-1", "amount": 99},
    encrypt=True,
    encryption_key="my-secret-passphrase",
)

Decrypt a popped message that was sent with client encryption using the same secret and the decrypt_payload helper (see poofmq.encryption).

API

  • PoofmqClient(base_url, api_key=None) – Create a client.
  • client.push(queue_id, event_type, payload, *, ttl_seconds=..., available_at=..., idempotency_key=..., encrypt=False, encryption_key=...) – Push a message.
  • client.pop(queue_id, *, visibility_timeout_seconds=..., wait_timeout_seconds=..., consumer_id=...) – Pop a message. Returns None when queue is empty.

Integration tests

From the monorepo, install the package in editable mode and run against a local API:

make sdk-generate
cd sdks/python
pip install -e .
POOFMQ_BASE_URL=http://localhost:8080 python -m test.integration.run

Or from repo root:

POOFMQ_BASE_URL=http://localhost:8080 python sdks/python/test/integration/run.py

(ensure sdks/python is on PYTHONPATH or install the package first with pip install -e sdks/python).

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

poofmq-1.0.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.

poofmq-1.0.0-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file poofmq-1.0.0.tar.gz.

File metadata

  • Download URL: poofmq-1.0.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for poofmq-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d03ed72b455fb82e380ff6f2954302ca79777567451ef894eebe4539b0f354f7
MD5 8f4e8dd7ebb5ad79eca35802c6470824
BLAKE2b-256 494a4d04d305843f5370023397cf94a227f4eb3ad009489a2ca8e9a6be0aa943

See more details on using hashes here.

File details

Details for the file poofmq-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: poofmq-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for poofmq-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dfbde7fc4ec59cad71210543f9814eecd36a0a655366fe071f3b0fe38ac13e8
MD5 35aa0ce770b46a1a59764bb9287f8404
BLAKE2b-256 904f88e349d6c4612aeb9349257c5b9f2f098120fadcdca6f2c8a5144ba6636b

See more details on using hashes here.

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