Skip to main content

Python SDK for FerricStore and FerricFlow

Project description

FerricStore Python SDK

Python SDK for FerricStore and FerricFlow.

Status: public alpha 0.1.0. APIs may change before 1.0.

What you use

  • QueueClient / AsyncQueueClient for durable queues.
  • WorkflowClient / AsyncWorkflowClient for explicit durable state machines.
  • FlowClient / AsyncFlowClient for advanced command-level control.
  • RetryPolicy, WorkerConfig, ValueConfig, and ExceptionPolicy for runtime defaults.
  • RawCodec by default, JsonCodec when you want JSON payloads.
  • client.command(...) as the Redis/FerricStore escape hatch.

FerricFlow is not a hidden deterministic replay engine. It is an explicit durable state pipeline:

create -> claim -> handler -> transition/complete/retry/fail

Handlers should be idempotent because work can be retried after lease expiry, worker crash, or explicit retry.

Install

pip install ferricstore

Local development:

python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"

Queue quickstart

from ferricstore import QueueClient

client = QueueClient.from_url("redis://127.0.0.1:6379/0")
emails = client.queue(type="email")

emails.enqueue("email-1", payload=b"welcome:user-1", idempotent=True)
emails.worker(concurrency=100, batch_size=500).run(send_email)

If the handler raises, the default worker policy is retry.

Workflow quickstart

from ferricstore import WorkflowClient, complete, transition

client = WorkflowClient.from_url("redis://127.0.0.1:6379/0")
order = client.workflow(
    type="order",
    initial_state="created",
    partition_by=("tenant_id", "order_id"),
)

@order.state("created")
def created(job):
    charge_card(job.payload)
    return transition("charged")

@order.state("charged")
def charged(job):
    send_receipt(job.id)
    return complete(result=b"ok")

order.start(
    "order-1",
    tenant_id="tenant-a",
    order_id="order-1",
    payload=b"order payload",
    idempotent=True,
)

Named values

Use named values when different states need different pieces of data:

emails.enqueue(
    "email-2",
    payload=b"small routing bytes",
    values={
        "template": b"welcome template bytes",
        "profile": b"user profile snapshot",
    },
)

emails.worker(claim_values=["template"]).run(send_email)

Only requested values are hydrated for the handler. Use ValueConfig or value_max_bytes in production to cap large value reads.

Async

import asyncio

from ferricstore import AsyncQueueClient


async def main():
    client = AsyncQueueClient.from_url("redis://127.0.0.1:6379/0")
    emails = client.queue(type="email")

    async def handler(job):
        await send_email_async(job.payload)

    await emails.worker(concurrency=100, batch_size=500).run(handler)


asyncio.run(main())

Production shape

Use one process/service to create work and a separate long-lived worker service to claim and complete work.

web/serverless producer -> FerricStore -> worker service

Before production, configure timeouts, connection pools, lease duration, backpressure behavior, graceful shutdown, and value hydration caps.

Docs

Examples

  • examples/order_workflow.py: two-state workflow.
  • examples/queue_worker.py: queue producer and worker.
  • examples/async_queue_worker.py: async queue producer and worker.
  • examples/state_machine_workflow.py: explicit workflow runner.
  • examples/native_commands.py: Redis/FerricStore command helpers.
  • examples/dbos_style_benchmark.py: DBOS-style throughput benchmark.

Contributing

See CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, and RELEASE.md.

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

ferricstore-0.1.0.tar.gz (164.8 kB view details)

Uploaded Source

Built Distribution

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

ferricstore-0.1.0-py3-none-any.whl (63.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ferricstore-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e7f850e4950063cd00f765f1a50199a439e9d751059bbc8f71348c1caa51f34
MD5 4b93fc43e213861da78384b4b0286c60
BLAKE2b-256 e6c1166094a7ebca05c2fb9eda4542438eab66840da043e0c20adc777b3228d5

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ferricstore/ferricstore-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 ferricstore-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for ferricstore-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cffd553a918cc0ce5cdcf28e0e07925b14dae78379b4f13289292e034478743
MD5 d4f7f83a99f9926340cf102e59e387c1
BLAKE2b-256 8d72c525eb6492dca80fe4d5932374408334adbef31231cd40817cc973c9266b

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ferricstore/ferricstore-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