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/AsyncQueueClientfor durable queues.WorkflowClient/AsyncWorkflowClientfor explicit durable state machines.FlowClient/AsyncFlowClientfor advanced command-level control.RetryPolicy,WorkerConfig,ValueConfig, andExceptionPolicyfor runtime defaults.RawCodecby default,JsonCodecwhen 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
- Documentation index
- Quickstart
- SDK guide
- Configuration
- Production readiness
- Data in workflows
- Worker runtime
- Async APIs
- Use cases
- Testing
- Troubleshooting
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e7f850e4950063cd00f765f1a50199a439e9d751059bbc8f71348c1caa51f34
|
|
| MD5 |
4b93fc43e213861da78384b4b0286c60
|
|
| BLAKE2b-256 |
e6c1166094a7ebca05c2fb9eda4542438eab66840da043e0c20adc777b3228d5
|
Provenance
The following attestation bundles were made for ferricstore-0.1.0.tar.gz:
Publisher:
publish.yml on ferricstore/ferricstore-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferricstore-0.1.0.tar.gz -
Subject digest:
3e7f850e4950063cd00f765f1a50199a439e9d751059bbc8f71348c1caa51f34 - Sigstore transparency entry: 1704836318
- Sigstore integration time:
-
Permalink:
ferricstore/ferricstore-python@36433624936241a91e945ee025d4a9f193e5ba28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ferricstore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@36433624936241a91e945ee025d4a9f193e5ba28 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cffd553a918cc0ce5cdcf28e0e07925b14dae78379b4f13289292e034478743
|
|
| MD5 |
d4f7f83a99f9926340cf102e59e387c1
|
|
| BLAKE2b-256 |
8d72c525eb6492dca80fe4d5932374408334adbef31231cd40817cc973c9266b
|
Provenance
The following attestation bundles were made for ferricstore-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ferricstore/ferricstore-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferricstore-0.1.0-py3-none-any.whl -
Subject digest:
7cffd553a918cc0ce5cdcf28e0e07925b14dae78379b4f13289292e034478743 - Sigstore transparency entry: 1704836368
- Sigstore integration time:
-
Permalink:
ferricstore/ferricstore-python@36433624936241a91e945ee025d4a9f193e5ba28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ferricstore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@36433624936241a91e945ee025d4a9f193e5ba28 -
Trigger Event:
push
-
Statement type: