Async task runtime for queue, polling, schedule, and webhook workloads.
Project description
onestep
onestep is a small async task runtime for queue, polling, schedule, and
webhook workloads. You declare a task with a source and optional sink, and
the runtime takes care of fetching, concurrency, retries, dead-lettering, and
telemetry.
- One decorator turns any async function into a managed task
- Pluggable connectors for memory, MySQL, RabbitMQ, Redis, SQS, Feishu
- Scheduling via interval, cron, webhook, or DB-backed queues
- Production-ready: retries, dead-letter, timeouts, state stores, metrics, and a control-plane reporter
- Two config styles: plain Python, or declarative YAML
- Python 3.9+
Quick start
Install:
pip install onestep
# optional extras:
pip install 'onestep[yaml]' # YAML task definitions
pip install 'onestep[control-plane]' # push telemetry to onestep-control-plane
Define an app, then run it with the onestep CLI:
from onestep import IntervalSource, OneStepApp
app = OneStepApp("billing-sync")
@app.task(source=IntervalSource.every(hours=1, immediate=True, overlap="skip"))
async def sync_billing(ctx, _):
print("syncing billing data")
onestep run your_package.tasks:app
onestep check your_package.tasks:app # validate the target before starting
What it does
| Capability | Where |
|---|---|
| Fetch work from a queue, schedule, webhook, or DB cursor | MemoryQueue, IntervalSource, CronSource, WebhookSource, MySQL table_queue / incremental / binlog, RabbitMQ queue, Redis stream, SQS queue |
| Emit results to a downstream sink | any source doubles as a sink; MySQL table_sink; HTTP http_sink; Feishu Bitable sink |
| Schedule recurring work | IntervalSource.every(...), CronSource(...) with overlap control (allow / skip / queue) |
| Ingest external events | WebhookSource with bearer auth, shared listeners, body parsing |
| Survive failures | retry policies, dead_letter sink, per-task timeout_s, failure classification (error / timeout / cancelled) |
| Track state | InMemoryStateStore, MySQL state/cursor stores; ctx.state namespace per task |
| Observe | @app.on_event hooks, InMemoryMetrics, StructuredEventLogger, execution events |
| Operate | control-plane reporter with remote commands: ping, shutdown, restart, drain, pause_task, resume_task, sync_now |
Core concepts
The whole runtime is built on four ideas:
OneStepApp— task registry and lifecycle managerSource— fetches data from a queue, schedule, webhook, or polling backendSink— publishes processed results downstreamDelivery— a single fetched item exposingack/retry/fail
from onestep import MemoryQueue, OneStepApp
app = OneStepApp("demo")
source = MemoryQueue("incoming")
sink = MemoryQueue("processed")
@app.task(source=source, emit=sink, concurrency=4)
async def double(ctx, item):
return {"value": item["value"] * 2}
async def main():
await source.publish({"value": 21})
await app.serve()
Connectors
Each backend ships as its own package so you only install what you use:
| Package | Provides | Install |
|---|---|---|
| core | MemoryQueue, IntervalSource, CronSource, WebhookSource, http_sink, runtime, reporter |
pip install onestep |
| MySQL | table_queue, incremental, binlog CDC, table_sink, state/cursor stores |
pip install onestep-mysql |
| PostgreSQL | same primitives as MySQL, backed by PostgreSQL | pip install onestep-postgres |
| RabbitMQ | queue with exchange/routing-key binding and prefetch |
pip install onestep-mq |
| Redis | stream with consumer groups, XACK, XCLAIM, maxlen |
pip install onestep-redis |
| SQS | queue with batched deletes and heartbeat visibility |
pip install onestep-sqs |
| Feishu Bitable | incremental source and upsert sink | pip install onestep-feishu-bitable |
Or install everything at once:
pip install 'onestep[all]'
Configuration styles
Plain Python
Best for application code. Each connector is a class you instantiate:
from onestep import OneStepApp
from onestep_redis import RedisConnector
app = OneStepApp("redis-demo")
redis = RedisConnector("redis://localhost:6379")
source = redis.stream("jobs", group="workers", batch_size=100)
out = redis.stream("processed")
@app.task(source=source, emit=out, concurrency=8)
async def process_job(ctx, item):
return {"job": item["job"], "status": "done"}
YAML
Best for deployment wiring. Keep business logic in Python; describe the runtime — app, resources, hooks, tasks — declaratively.
app:
name: billing-sync
resources:
tick:
type: interval
minutes: 5
immediate: true
tasks:
- name: sync_billing
source: tick
handler:
ref: your_package.handlers.billing:sync_billing
onestep run worker.yaml
onestep check --strict worker.yaml # schema validation, unknown-field detection
onestep init billing-sync # scaffold a minimal YAML project
The full YAML schema, resource types, conditional routing, and state binding
are covered in docs/yaml-task-definition.md.
Deployment
- systemd — minimal unit + preflight check template in
deploy/ - Official worker image — run YAML workers in Docker without packaging:
docker run --rm \ -e ONESTEP_TARGET=/workspace/worker.yaml \ -v "$PWD:/workspace" \ ghcr.io/mic1on/onestep-worker:1.2.7
Seedeploy/worker-runtime-image.md. - Embed in a web app — recommended shape for FastAPI/Django in
deploy/web-service-integration.md.
Control plane
onestep can push runtime telemetry (heartbeat, topology, metrics, events) to
onestep-control-plane over a single WebSocket and
accept remote commands — with no connector or task-code changes.
app:
name: billing-sync
reporter: true
Required env: ONESTEP_CONTROL_PLANE_URL, ONESTEP_CONTROL_PLANE_TOKEN.
For identity, multi-replica guidance, env vars, and a local demo, see
docs/stable-instance-identity.md.
Examples
Runnable examples live in example/. Highlights:
# 5-second interval task
SYNC_INTERVAL_SECONDS=5 PYTHONPATH=src onestep run example.cli_app:app
# end-to-end: webhook -> queue -> worker -> dead-letter, with metrics + logs
PYTHONPATH=src python3 example/runtime_showcase.py
Upgrading
1.0.0 was a runtime rewrite. If you're coming from 0.5.x, see
MIGRATION-0.5-to-1.0.0.md for the old-to-new API
mapping, unsupported features, and rollout guidance.
More
docs/yaml-task-definition.md— YAML schemadocs/core-reliability.md— stable API, delivery semantics, plugin compatibility, and release checklistdocs/stable-instance-identity.md— reporter identity resolutiondocs/agent-ws-protocol.md— agent WS protocoldeploy/— deployment templates
License
MIT
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 onestep-1.4.5.tar.gz.
File metadata
- Download URL: onestep-1.4.5.tar.gz
- Upload date:
- Size: 126.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc30f64b565f6e45754863f0fbbfba881804f99dc8ac9fd38387f5b7ce43059
|
|
| MD5 |
a8b74949ccb336595062f730f6d4fd7c
|
|
| BLAKE2b-256 |
606aa1db4112af5c2db4864e53a635c21937d833959ce82ee0ff267f416f8a0f
|
Provenance
The following attestation bundles were made for onestep-1.4.5.tar.gz:
Publisher:
release.yml on mic1on/onestep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onestep-1.4.5.tar.gz -
Subject digest:
5cc30f64b565f6e45754863f0fbbfba881804f99dc8ac9fd38387f5b7ce43059 - Sigstore transparency entry: 2164198801
- Sigstore integration time:
-
Permalink:
mic1on/onestep@f765730841d1f25c50d9c24749fb486908ef4f84 -
Branch / Tag:
refs/tags/v1.4.5 - Owner: https://github.com/mic1on
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f765730841d1f25c50d9c24749fb486908ef4f84 -
Trigger Event:
push
-
Statement type:
File details
Details for the file onestep-1.4.5-py3-none-any.whl.
File metadata
- Download URL: onestep-1.4.5-py3-none-any.whl
- Upload date:
- Size: 79.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 |
24df86c3bbe6cb53d77dfd23a90c22908be50fb12ed941b7d45a476d193d6f8f
|
|
| MD5 |
70ae6b3f0f389ed18fdd7a10f132f08f
|
|
| BLAKE2b-256 |
00437bc3890cbd30cacacf5a13e955c310e68096fc366652ae4e9033754bbc8b
|
Provenance
The following attestation bundles were made for onestep-1.4.5-py3-none-any.whl:
Publisher:
release.yml on mic1on/onestep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onestep-1.4.5-py3-none-any.whl -
Subject digest:
24df86c3bbe6cb53d77dfd23a90c22908be50fb12ed941b7d45a476d193d6f8f - Sigstore transparency entry: 2164198885
- Sigstore integration time:
-
Permalink:
mic1on/onestep@f765730841d1f25c50d9c24749fb486908ef4f84 -
Branch / Tag:
refs/tags/v1.4.5 - Owner: https://github.com/mic1on
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f765730841d1f25c50d9c24749fb486908ef4f84 -
Trigger Event:
push
-
Statement type: