Python SDK for background job processing via Relayway API
Project description
relayway
Python SDK for enqueueing background jobs via the RelayWay API.
Installation
pip install .
Configuration
Set environment variables (or use a .env file):
export RELAYWAY_API_KEY="sk_xxx" # Your RelayWay API key
export RELAYWAY_WEBHOOK_SECRET="whsec_xxx" # Shared secret for webhook auth
export RELAYWAY_BASE_URL="https://api.relayway.io" # RelayWay API URL
export RELAYWAY_ORIGIN="https://myapp.com" # Your app's public URL
Quick start
from fastapi import FastAPI
from relayway import background, relayway_router
app = FastAPI()
app.include_router(relayway_router)
@background(name="send-email")
def send_email(to: str, subject: str) -> dict:
send_actual_email(to, subject)
return {"sent": True}
# Call the function — it enqueues instead of executing locally
result = await send_email("alice@example.com", "Welcome!")
print(result) # {"id": "task-abc", "status": "pending"}
How it works
- Registration —
@background()registers your function in the SDK's internal registry. - Enqueue — Calling the function sends the arguments as a task payload to the RelayWay API.
- Execution — The RelayWay worker picks up the task and POSTs to your app at
/relayway/webhook/{name}. The router verifies the HMAC signature, looks up your function, and calls it with the original arguments. - Response — The function's return value is sent back to the worker.
API reference
@background(name="my-func")
Decorator that marks a function for background execution.
name— unique identifier (defaults tofunc.__name__). The worker calls back to/relayway/webhook/{name}.
relayway_router
A FastAPI APIRouter you mount on your app. Provides the webhook endpoint:
POST /relayway/webhook/{name}— worker callback, HMAC-protected.
Run tests
uv run --group dev pytest -q
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
relayway-0.2.0.tar.gz
(7.9 kB
view details)
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 relayway-0.2.0.tar.gz.
File metadata
- Download URL: relayway-0.2.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd9d185e7d0beeba70e2b229e8f65145bbae433dbf743c627c151a31208f1800
|
|
| MD5 |
0a3a734f17b33f9d0eb6a0353933cf11
|
|
| BLAKE2b-256 |
c6d44206896c218e1b2076caff2e3382598d8d1a348f548b675891796fde9ce7
|
File details
Details for the file relayway-0.2.0-py3-none-any.whl.
File metadata
- Download URL: relayway-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08d704b0f9d411dd6df434e5dc1094ff2d83cff1abcc82270f8da4ae4a02ce1e
|
|
| MD5 |
0dc220a98dc2c48535c8e3211522af9b
|
|
| BLAKE2b-256 |
7e58febc6d1611acdad435b6c1c0a04a6bfb6165e9411b85a99e41f3c51397fc
|