Small framework for Temporal development
Project description
Temporal-boost
Documentation is available on GH pages
Small framework based on temporalio/sdk-python - create Temporal microservices as fast as you can
Requirements
- Python >= 3.10
Features
- Create Temporal workers with FastAPI-style
- Add CRON workers with one code line
- Append ASGI (ex. FastAPI) workers like Temporal
- Auto documentation with web UI (like SwaggerUI in FastAPI)
- Build-in logger and OTLP tracer
Quick start
from temporal_boost import BoostApp
from temporalio import activity
from temporalio import workflow
# Create `BoostApp` object
app = BoostApp()
# Describe your activities/workflows
@activity.defn(name="test_boost_activity_1")
async def test_boost_activity_1(foo: str, bar: str) -> str:
app.logger.info("This is built-in logger")
return f"1_{foo}{bar}"
@activity.defn(name="test_boost_activity_2")
async def test_boost_activity_2(foo: str, bar: str) -> str:
return f"2_{foo}{bar}"
@workflow.defn(name="TestCronWorkflow", sandboxed=False)
class TestCronWorkflow:
@workflow.run
async def run(self) -> None:
app.logger.warning("With is cron workflow")
return None
# Add async workers to your app (FastAPI style)
app.add_worker(
"worker_1",
"task_q_1",
activities=[test_boost_activity_1],
metrics_endpoint="0.0.0.0:9000"
)
app.add_worker(
"worker_2",
"task_q_2",
activities=[test_boost_activity_2]
)
# Example of CRON worker
app.add_worker(
"test_cron",
"task_q_3",
workflows=[TestCronWorkflow],
cron_schedule="* * * * *",
cron_runner=TestCronWorkflow.run
)
# Run your app and start workers with CLI
app.run()
python3 main.py
# Usage: main.py [OPTIONS] COMMAND [ARGS]...
# Options:
# --install-completion [bash|zsh|fish|powershell|pwsh]
# Install completion for the specified shell.
# --show-completion [bash|zsh|fish|powershell|pwsh]
# Show completion for the specified shell, to
# copy it or customize the installation.
# --help Show this message and exit.
# Commands:
# cron
# run
python3 main.py run
# Usage: main.py run [OPTIONS] COMMAND [ARGS]...
# Options:
# --help Show this message and exit.
# Commands:
# all
# test_cron
# worker_1
# worker_2
python3 main.py run worker_1
# 2023-09-20T21:25:12 | INFO | Worker worker_1 was registered in CLI
# 2023-09-20T21:25:12 | INFO | Worker worker_2 was registered in CLI
# 2023-09-20T21:25:12 | INFO | Worker test_cron was registered in CLI
# 2023-09-20T21:25:12 | INFO | Worker worker_1 started on task_q_1 queue
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
temporal_boost-1.0.2.tar.gz
(15.5 kB
view details)
Built Distribution
File details
Details for the file temporal_boost-1.0.2.tar.gz
.
File metadata
- Download URL: temporal_boost-1.0.2.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ae47e7d5d0088318827779a77613b5278e0298a6e692579f57d477a237c775d |
|
MD5 | 6be24d1cee11a5184364970a0fb1814a |
|
BLAKE2b-256 | ecdcca03b11647fd0368bf3d02e1e9d5f1b9dc6fa40e451e3f8383572213d257 |
File details
Details for the file temporal_boost-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: temporal_boost-1.0.2-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e28276231b55fd81017ab881186d37119278a4beca8abd4f9e8a34147a11638 |
|
MD5 | 5b804b69db4d319cca9f12efe1a9a0e6 |
|
BLAKE2b-256 | c9ff79aae1f263f23ca911b168838845bdc533056a6db9ef8bfcc04c71ca61ca |