DBOS durable execution framework for Go. Use when implementing resilient, failure-recoverable applications with durable workflows, steps, queues, and workflow communication patterns. Triggers on DBOS Go, durable execution Go, resilient workflows Go, saga pattern Go, or when building fault-tolerant Go applications.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cloud-and-observability:dbos-goThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
DBOS provides durable execution so you can write programs that are resilient to any failure. When interrupted, workflows automatically resume from their last completed step. Requires PostgreSQL as its system database.
DBOS provides durable execution so you can write programs that are resilient to any failure. When interrupted, workflows automatically resume from their last completed step. Requires PostgreSQL as its system database.
dbos.DBOSContext plus one serializable inputselectdbos.RunAsStep()context.Context and return serializable value + errordbos.NewWorkflowQueue()package main
import (
"context"
"fmt"
"os"
"time"
"github.com/dbos-inc/dbos-transact-golang/dbos"
)
func main() {
dbosContext, err := dbos.NewDBOSContext(context.Background(), dbos.Config{
AppName: "my-app",
DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),
})
if err != nil {
panic(fmt.Sprintf("Initializing DBOS failed: %v", err))
}
// Register workflows BEFORE Launch
dbos.RegisterWorkflow(dbosContext, myWorkflow)
err = dbos.Launch(dbosContext)
if err != nil {
panic(fmt.Sprintf("Launching DBOS failed: %v", err))
}
defer dbos.Shutdown(dbosContext, 5*time.Second)
// Application logic (HTTP server, etc.)
}
func myWorkflow(ctx dbos.DBOSContext, input string) (string, error) {
result1, err := dbos.RunAsStep(ctx, func(stepCtx context.Context) (string, error) {
return callExternalAPI(stepCtx, input)
}, dbos.WithStepName("callAPI"))
if err != nil {
return "", err
}
result2, err := dbos.RunAsStep(ctx, func(stepCtx context.Context) (string, error) {
return processData(stepCtx, result1)
}, dbos.WithStepName("processData"))
if err != nil {
return "", err
}
return result2, nil
}
func fetchWithRetry(ctx dbos.DBOSContext, url string) (string, error) {
return dbos.RunAsStep(
ctx,
func(stepCtx context.Context) (string, error) {
resp, err := http.Get(url)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
return string(body), nil
},
dbos.WithStepName("fetchURL"),
dbos.WithStepMaxRetries(10),
dbos.WithMaxInterval(30*time.Second),
dbos.WithBackoffFactor(2.0),
dbos.WithBaseInterval(500*time.Millisecond),
)
}
func main() {
dbosContext := initDBOS()
queue := dbos.NewWorkflowQueue(dbosContext, "task_queue",
dbos.WithWorkerConcurrency(5))
// Or with rate limiting
rateLimitedQueue := dbos.NewWorkflowQueue(dbosContext, "api_queue",
dbos.WithRateLimiter(&dbos.RateLimiter{
Limit: 100,
Period: 60.0, // 100 requests per minute
}))
dbos.RegisterWorkflow(dbosContext, taskWorkflow)
dbos.Launch(dbosContext)
}
func enqueueTask(ctx dbos.DBOSContext, queue dbos.WorkflowQueue, taskID int) error {
handle, err := dbos.RunWorkflow(ctx, taskWorkflow, taskID,
dbos.WithQueue(queue.Name))
if err != nil {
return err
}
_, err = handle.GetResult()
return err
}
const PaymentTopic = "payment_status"
func checkoutWorkflow(ctx dbos.DBOSContext, orderID string) (string, error) {
// Wait up to 5 minutes for payment confirmation
notification, err := dbos.Recv(ctx, PaymentTopic, 300)
if err != nil {
return "", fmt.Errorf("payment timeout: %w", err)
}
if notification.Status == "completed" {
return "order_completed", nil
}
return "payment_failed", nil
}
func paymentWebhook(dbosContext dbos.DBOSContext, workflowID string, status string) error {
return dbos.Send(dbosContext, workflowID, PaymentNotification{Status: status}, PaymentTopic)
}
const PaymentURLKey = "payment_url"
func checkoutWorkflow(ctx dbos.DBOSContext, order Order) (string, error) {
url := generatePaymentURL(order)
err := dbos.SetEvent(ctx, PaymentURLKey, url)
if err != nil {
return "", err
}
// Continue processing...
}
func checkoutHandler(dbosContext dbos.DBOSContext, w http.ResponseWriter, r *http.Request) {
handle, _ := dbos.RunWorkflow(dbosContext, checkoutWorkflow, order)
url, err := dbos.GetEvent[string](dbosContext, handle.GetWorkflowID(), PaymentURLKey, 30*time.Second)
if err != nil {
http.Error(w, "Timeout", http.StatusGatewayTimeout)
return
}
http.Redirect(w, r, url, http.StatusSeeOther)
}
func scheduledTaskWorkflow(ctx dbos.DBOSContext, delay time.Duration) (string, error) {
_, err := dbos.Sleep(ctx, delay)
if err != nil {
return "", err
}
return dbos.RunAsStep(ctx, func(stepCtx context.Context) (string, error) {
return executeTask(stepCtx)
})
}
func main() {
dbosContext := initDBOS()
// Run daily at 2:00 AM
dbos.RegisterWorkflow(dbosContext, dailyBackup,
dbos.WithSchedule("0 0 2 * * *"))
// Run every 15 minutes
dbos.RegisterWorkflow(dbosContext, healthCheck,
dbos.WithSchedule("0 */15 * * * *"))
dbos.Launch(dbosContext)
}
func handlePayment(dbosContext dbos.DBOSContext, payment Payment) error {
// Same workflow ID = same execution (prevents duplicates)
handle, err := dbos.RunWorkflow(dbosContext, processPayment, payment,
dbos.WithWorkflowID(payment.ID))
if err != nil {
return err
}
_, err = handle.GetResult()
return err
}
queue := dbos.NewWorkflowQueue(dbosContext, "priority_queue",
dbos.WithPriorityEnabled())
// Lower number = higher priority
dbos.RunWorkflow(ctx, urgentTask, data,
dbos.WithQueue(queue.Name),
dbos.WithPriority(1)) // High priority
func parentWorkflow(ctx dbos.DBOSContext, items []Item) ([]Result, error) {
var results []Result
for _, item := range items {
handle, err := dbos.RunWorkflow(ctx, processItemWorkflow, item)
if err != nil {
return nil, err
}
result, err := handle.GetResult()
if err != nil {
return nil, err
}
results = append(results, result)
}
return results, nil
}
func main() {
dbosContext := initDBOS()
dbos.RegisterWorkflow(dbosContext, orderWorkflow)
dbos.Launch(dbosContext)
defer dbos.Shutdown(dbosContext, 5*time.Second)
r := gin.Default()
r.POST("/orders", func(c *gin.Context) {
var order Order
if err := c.ShouldBindJSON(&order); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
handle, err := dbos.RunWorkflow(dbosContext, orderWorkflow, order)
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
c.JSON(202, gin.H{"workflow_id": handle.GetWorkflowID(), "status": "processing"})
})
r.Run(":8080")
}
dbos.Sleep() or wrap time.Now() in stepscontext.Context as first parameter(T, error) where T is serializabledbos.WithStepName() for clarity in logs/debuggingdbos.DBOSContext as first parameterdbos.Launch()npx claudepluginhub zach-source/claude-plugins --plugin cloud-and-observabilityGuides building reliable, fault-tolerant Go applications using DBOS durable workflows, steps, queues, communication, configuration, and testing best practices.
Implements durable multi-step workflows on Cloudflare Workers with retries, state persistence, sleeps, event waiting, and NonRetryableError handling. Use for long-running tasks.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.