Show HN: DBOSify – 基于 Postgres 构建的 Temporal 直接替代方案
Show HN: DBOSify – Drop-in Temporal replacement built on Postgres

原始链接: https://github.com/dbos-inc/dbosify-py

**DBOSify** 是 Temporal Python SDK 的直接替代方案,它使用 PostgreSQL 数据库取代了外部的 Temporal 服务器。通过利用 DBOS Transact,开发者仅需使用 Postgres 作为基础设施,即可构建包含活动(activities)、信号(signals)和重试(retries)在内的持久化工作流。 主要功能包括: * **易于使用:** 只需将 `temporalio` 的导入替换为 `dbosify` 并连接到 Postgres 实例即可。 * **持久性:** 工作流会在 Postgres 中进行检查点保存,确保可靠的状态管理、自动重试和故障恢复。非确定性操作和计时器会被保存为持久化步骤。 * **运维简单:** 无需复杂的 Temporal 服务器集群。但请注意,它与 Temporal **不兼容**;它专为仅使用 Python 的应用程序设计,旨在用 DBOS 等效组件替换整个 Temporal 堆栈(包括 UI 和 CLI)。 * **验证:** 该库通过移植的 Temporal 单元测试、示例应用程序验证以及签名一致性测试来确保兼容性。 对于希望获得类 Temporal 工作流持久性,同时又不想承担管理外部独立 Temporal 基础设施开销的开发者来说,DBOSify 是理想的选择。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN: DBOSify – 基于 Postgres 构建的 Temporal 直接替换方案 (github.com/dbos-inc) 7 分,由 KraftyOne 发布于 1 小时前 | 隐藏 | 过往 | 收藏 | 2 条评论 帮助 hhhhha 2 分钟前 | 下一条 [–] 嗨…… 回复 KraftyOne 1 小时前 | 上一条 [–] 嗨 HN,我是 Peter,DBOSify 的创建者。很高兴在此回答大家的任何问题! 回复 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

DBOSify is a drop-in replacement for Temporal Python that uses Postgres (through DBOS Transact) instead of a Temporal server. This lets you run durable workflows, activities, signals, updates, retries, and recovery without needing any infrastructure except Postgres.

DBOSify architecture: a DBOSify Client and DBOSify Workers coordinate through Postgres, which handles workflow orchestration

To use this library, import dbosify instead of temporalio and connect your workers and clients to a Postgres database:

DBOSify is a drop-in replacement for Temporal Python

To install:

This is a drop-in replacement: simply import dbosify instead of temporalio and connect your clients and workers to a Postgres database instead of a Temporal server. Further documentation here.

import asyncio
import os
from datetime import timedelta

from dbosify import activity, workflow
from dbosify.client import Client
from dbosify.worker import Worker

# Set this to a connection string to your Postgres database
DB_URL = os.environ.get("DBOS_SYSTEM_DATABASE_URL")


@activity.defn
async def compose_greeting(name: str) -> str:
    return f"Hello, {name}!"


@workflow.defn
class GreetingWorkflow:
    @workflow.run
    async def run(self, name: str) -> str:
        return await workflow.execute_activity(
            compose_greeting, name, start_to_close_timeout=timedelta(seconds=10)
        )


async def main() -> None:
    worker = Worker(
        DB_URL,
        task_queue="greetings",
        workflows=[GreetingWorkflow],
        activities=[compose_greeting],
    )
    async with worker:
        async with await Client.connect(DB_URL) as client:
            result = await client.execute_workflow(
                GreetingWorkflow.run, "World", id="greeting-1", task_queue="greetings"
            )
            print(result)  # Hello, World!


if __name__ == "__main__":
    asyncio.run(main())

DBOSify runs each Temporal workflow as a Postgres-backed DBOS workflow. A deterministic interpreter runs the workflow (both its main coroutine and its signal, update, and query handlers) on a virtual event loop that only advances when an event arrives. Using DBOS steps and workflow communication primitives, all nondeterministic actions are checkpointed in Postgres before the workflow observes them.

  • Activities and timers become DBOS steps and durable sleeps, each checkpointed on completion.
  • Signals, updates, and cancellations are durable messages delivered through Postgres using LISTEN/NOTIFY.
  • Recovery re-runs the workflow on a new worker: the interpreter replays the same sequence of operations against the recorded checkpoints, so execution resumes where it left off and completes exactly once.
  • Namespaces each map to their own Postgres schema; a Client wraps a DBOS client and a Worker wraps the DBOS runtime.

As DBOSify is a drop-in replacement for Temporal, its tests cover both correctness and conformance with Temporal using the following strategies:

  • Ports of all relevant Temporal Python unit and integration tests
  • Ports of relevant Temporal Python sample applications, verifying DBOSify is a drop-in replacement
  • New unit and integration tests, with an emphasis on kill-and-recover tests verifying deterministic failure recovery
  • Signature parity tests mechanically asserting the public APIs of these libraries are identical (with documented exceptions)
  • No wire protocol compatibility. There is no gRPC wire compatibility. Temporal SDKs in other languages cannot connect. This replaces the Temporal server and Python SDK altogether for Python-only applications.
  • No Temporal Web UI, temporal CLI, or tctl. You operate workflows with DBOS's workflow-management APIs and DBOS Conductor instead.

See this documentation for information on architectural differences and feature compatibility.

联系我们 contact @ memedata.com