跳到正文
Skillpedia
API 与服务器(后端)48k · #4342

dbos-golang

它能做什么

这份指南介绍如何使用一种名为 DBOS 的技术,构建可靠且具备容错能力的 Go 程序。它可以帮你把代码组织成“工作流”(workflows)和“步骤”(steps)两类模块。

适用场景

  • ✓当你要把 DBOS 添加到现有的 Go 项目中时。
  • ✓当你要创建新的程序模块(工作流和步骤)时。
  • ✓当你要使用队列来控制同时运行的任务数量时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/dbos-golang/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/dbos-golang/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何为我的 Go 应用配置 DBOS?”

每周 5 个新技能,1 分钟读完。

工作原理

DBOS 会把你的代码组织成“工作流”(较大的流程)和“步骤”(工作流中较小的任务)。即使出现意外,它也能确保任务可靠地执行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

DBOS Go Best Practices

Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows.

When to Use

Reference these guidelines when:

  • Adding DBOS to existing Go code
  • Creating workflows and steps
  • Using queues for concurrency control
  • Implementing workflow communication (events, messages, streams)
  • Configuring and launching DBOS applications
  • Using the DBOS Client from external applications
  • Testing DBOS applications

Rule Categories by Priority

Priority Category Impact Prefix
1 Lifecycle CRITICAL lifecycle-
2 Workflow CRITICAL workflow-
3 Step HIGH step-
4 Queue HIGH queue-
5 Communication MEDIUM comm-
6 Pattern MEDIUM pattern-
7 Testing LOW-MEDIUM test-
8 Client MEDIUM client-
9 Advanced LOW advanced-

Critical Rules

Installation

Install the DBOS Go module:

go get github.com/dbos-inc/dbos-transact-golang/dbos@latest

DBOS Configuration and Launch

A DBOS application MUST create a context, register workflows, and launch before running any workflows:

package main

import (
	"context"
	"log"
	"os"
	"time"

	"github.com/dbos-inc/dbos-transact-golang/dbos"
)

func main() {
	ctx, err := dbos.NewDBOSContext(context.Background(), dbos.Config{
		AppName:     "my-app",
		DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),
	})
	if err != nil {
		log.Fatal(err)
	}
	defer dbos.Shutdown(ctx, 30*time.Second)

	dbos.RegisterWorkflow(ctx, myWorkflow)

	if err := dbos.Launch(ctx); err != nil {
		log.Fatal(err)
	}
}

Workflow and Step Structure

Workflows are comprised of steps. Any function performing complex operations or accessing external services must be run as a step using dbos.RunAsStep:

func fetchData(ctx context.Context) (string, error) {
	resp, err := http.Get("https://api.example.com/data")
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	return string(body), nil
}

func myWorkflow(ctx dbos.DBOSContext, input string) (string, error) {
	result, err := dbos.RunAsStep(ctx, fetchData, dbos.WithStepName("fetchData"))
	if err != nil {
		return "", err
	}
	return result, nil
}

Key Constraints

  • Do NOT start or enqueue workflows from within steps
  • Do NOT use uncontrolled goroutines to start workflows - use dbos.RunWorkflow with queues or dbos.Go/dbos.Select for concurrent steps
  • Workflows MUST be deterministic - non-deterministic operations go in steps
  • Do NOT modify global variables from workflows or steps
  • All workflows and queues MUST be registered before calling Launch()

How to Use

Read individual rule files for detailed explanations and examples:

references/lifecycle-config.md
references/workflow-determinism.md
references/queue-concurrency.md

References

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题

什么是“工作流”?

工作流是一系列任务的组合,共同完成一项较大且可靠的操作。

什么是“步骤”?

步骤是工作流中较小的工作单元。与外部系统交互的任务,或比较复杂的任务,都应该设计成步骤。

为什么要使用 DBOS?

它能让你的 Go 程序更加健壮,即使发生故障也能继续运行,并确保任务被正确完成。

详情

作者的原始描述

Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows. Use when adding DBOS to existing Go code, creating workflows and steps, or using queues for concurrency control.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4342
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能