DBOS Go SDK for building reliable, fault-tolerant applications with durable workflows. Use this skill when writing Go code with DBOS, creating workflows and steps, using queues, using the DBOS Client from external applications, or building Go applications that need to be resilient to failures.
Add this skill
npx mdskills install sickn33/dbos-golangSolid foundation with clear workflow patterns but lacks critical details and referenced files are missing
1---2name: dbos-golang3description: DBOS Go SDK for building reliable, fault-tolerant applications with durable workflows. Use this skill when writing Go code with DBOS, creating workflows and steps, using queues, using the DBOS Client from external applications, or building Go applications that need to be resilient to failures.4risk: safe5source: https://docs.dbos.dev/6license: MIT7metadata:8 author: dbos9 version: "1.0.0"10 organization: DBOS11 date: February 202612 abstract: Comprehensive guide for building fault-tolerant Go applications with DBOS. Covers workflows, steps, queues, communication patterns, and best practices for durable execution.13---1415# DBOS Go Best Practices1617Guide for building reliable, fault-tolerant Go applications with DBOS durable workflows.1819## When to Use2021Reference these guidelines when:22- Adding DBOS to existing Go code23- Creating workflows and steps24- Using queues for concurrency control25- Implementing workflow communication (events, messages, streams)26- Configuring and launching DBOS applications27- Using the DBOS Client from external applications28- Testing DBOS applications2930## Rule Categories by Priority3132| Priority | Category | Impact | Prefix |33|----------|----------|--------|--------|34| 1 | Lifecycle | CRITICAL | `lifecycle-` |35| 2 | Workflow | CRITICAL | `workflow-` |36| 3 | Step | HIGH | `step-` |37| 4 | Queue | HIGH | `queue-` |38| 5 | Communication | MEDIUM | `comm-` |39| 6 | Pattern | MEDIUM | `pattern-` |40| 7 | Testing | LOW-MEDIUM | `test-` |41| 8 | Client | MEDIUM | `client-` |42| 9 | Advanced | LOW | `advanced-` |4344## Critical Rules4546### Installation4748Install the DBOS Go module:4950```bash51go get github.com/dbos-inc/dbos-transact-golang/dbos@latest52```5354### DBOS Configuration and Launch5556A DBOS application MUST create a context, register workflows, and launch before running any workflows:5758```go59package main6061import (62 "context"63 "log"64 "os"65 "time"6667 "github.com/dbos-inc/dbos-transact-golang/dbos"68)6970func main() {71 ctx, err := dbos.NewDBOSContext(context.Background(), dbos.Config{72 AppName: "my-app",73 DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),74 })75 if err != nil {76 log.Fatal(err)77 }78 defer dbos.Shutdown(ctx, 30*time.Second)7980 dbos.RegisterWorkflow(ctx, myWorkflow)8182 if err := dbos.Launch(ctx); err != nil {83 log.Fatal(err)84 }85}86```8788### Workflow and Step Structure8990Workflows are comprised of steps. Any function performing complex operations or accessing external services must be run as a step using `dbos.RunAsStep`:9192```go93func fetchData(ctx context.Context) (string, error) {94 resp, err := http.Get("https://api.example.com/data")95 if err != nil {96 return "", err97 }98 defer resp.Body.Close()99 body, _ := io.ReadAll(resp.Body)100 return string(body), nil101}102103func myWorkflow(ctx dbos.DBOSContext, input string) (string, error) {104 result, err := dbos.RunAsStep(ctx, fetchData, dbos.WithStepName("fetchData"))105 if err != nil {106 return "", err107 }108 return result, nil109}110```111112### Key Constraints113114- Do NOT start or enqueue workflows from within steps115- Do NOT use uncontrolled goroutines to start workflows - use `dbos.RunWorkflow` with queues or `dbos.Go`/`dbos.Select` for concurrent steps116- Workflows MUST be deterministic - non-deterministic operations go in steps117- Do NOT modify global variables from workflows or steps118- All workflows and queues MUST be registered before calling `Launch()`119120## How to Use121122Read individual rule files for detailed explanations and examples:123124```125references/lifecycle-config.md126references/workflow-determinism.md127references/queue-concurrency.md128```129130## References131132- https://docs.dbos.dev/133- https://github.com/dbos-inc/dbos-transact-golang134
Full transparency — inspect the skill content before installing.