Skill

Implement DBOS Go Best Practices for Reliable Apps

Priority-ranked best practices for building fault-tolerant Go applications with DBOS durable workflows.

Works with github

91
Spark score
out of 100
Updated 22 days ago
Version 14.0.0

Add to Favorites

Why it matters

Build robust and fault-tolerant Go applications using DBOS durable workflows. This asset provides essential guidelines for integrating DBOS, managing workflows and steps, and ensuring reliable communication and concurrency.

Outcomes

What it gets done

01

Integrate DBOS into existing Go applications.

02

Define and manage DBOS workflows and their constituent steps.

03

Implement efficient concurrency control using queues.

04

Ensure deterministic workflow execution and proper testing.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-dbos-golang | bash

Overview

DBOS Go Best Practices

A priority-ranked rule set for building fault-tolerant Go applications on DBOS durable workflows, covering lifecycle setup, workflow/step structure, queue concurrency, and communication. Use when adding DBOS to Go code, creating workflows and steps, configuring queues, or testing DBOS applications.

What it does

DBOS Go Best Practices is a guide for building reliable, fault-tolerant Go applications with DBOS durable workflows. It organizes its rules into nine priority-ranked categories - Lifecycle (critical, lifecycle- prefix), Workflow (critical, workflow-), Step (high, step-), Queue (high, queue-), Communication (medium, comm-), Pattern (medium, pattern-), Testing (low-medium, test-), Client (medium, client-), and Advanced (low, advanced-) - and documents the critical rules directly: installing the DBOS Go module, creating a DBOS context and registering workflows before calling dbos.Launch(), and structuring workflows as a composition of steps where any function performing complex operations or accessing external services must run via dbos.RunAsStep.

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

It states five hard constraints: never start or enqueue workflows from within steps; never use uncontrolled goroutines to start workflows - use dbos.RunWorkflow with queues, or dbos.Go/dbos.Select for concurrent steps; workflows must be deterministic, with non-deterministic operations pushed into steps; never modify global variables from workflows or steps; and all workflows and queues must be registered before calling Launch().

When to use - and when NOT to

Reference these guidelines when adding DBOS to existing Go code, creating new 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, or testing DBOS applications end to end.

Inputs and outputs

Given a DBOS Go application task, the skill's critical-rules section directly supplies a working context-creation/registration/launch skeleton (dbos.NewDBOSContext, dbos.RegisterWorkflow, dbos.Launch, dbos.Shutdown with a 30-second timeout) and a workflow/step example showing an HTTP-fetching step wrapped with dbos.RunAsStep and dbos.WithStepName. Deeper category-specific rule files are read on demand: references/lifecycle-config.md, references/workflow-determinism.md, and references/queue-concurrency.md, each covering one of the nine rule categories in more detail than the critical-rules summary provides.

Integrations

Built on the github.com/dbos-inc/dbos-transact-golang/dbos Go module, installed via go get. Points to the official DBOS documentation at docs.dbos.dev and its source repository on GitHub for further reference, and instructs readers to consult the individual rule files under references/ for detailed explanations and worked examples beyond the critical-rules summary.

Who it's for

Go developers building fault-tolerant, durable-workflow applications with DBOS who need a prioritized, numbered rule set - not just an API reference - covering lifecycle setup, workflow/step structure, queue concurrency, cross-workflow communication, and testing, with hard constraints called out explicitly to avoid the most common correctness mistakes: non-deterministic workflows, uncontrolled goroutines, and unregistered workflows at launch time.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.