$ show cschleiden/go-workflows
go-workflows is a Go library for building durable, fault-tolerant workflow applications. It implements an event-sourced execution engine inspired by Temporal/Cadence: workflows are modeled as histories of events, and workers execute them by replaying those histories against backend queues. The library exposes a public client API for starting, signaling, and waiting on workflows, and provides a workflow/activity authoring model with sub-workflows, timers, signals, retries, cancellation, and context propagation. Execution is built on a custom coroutine-based async runtime (internal/sync) that gives workflows deterministic control flow, and multiple storage backends (Redis, MySQL, PostgreSQL, SQLite, plus in-memory/monoprocess) implement the same backend interface. Key entry points include the client package, the worker package, the workflow/activity authoring packages, and the tester package for unit testing workflows without a real backend. The repository also contains a separate static analyzer module (analyzer/) that enforces workflow determinism at compile time, and a benchmark tool (bench/) for comparing backend performance. External dependencies include OpenTelemetry for tracing, slog for structured logging, and backend-specific drivers for Redis, MySQL, PostgreSQL, and SQLite. CI runs tests with the race detector across all backends, and Docker Compose provides the required databases. The codebase is substantial and well-tested, but carries maintainability debt: each backend duplicates significant logic (diagnostics queries, event insertion), Redis uses hand-written Lua scripts that can drift, and the embedded diagnostic web app requires a separate Node.js build step. The separate analyzer module also risks version drift from the main module. Despite these caveats, the core abstractions are clean and several components are genuinely reusable.
The LLM identified 5 files worth highlighting for reuse:
Custom coroutine-based async primitives (Context, Future, Channel) that give Go workflows deterministic, resumable execution. This is the core runtime trick that lets workflows be replayed from event histories, and it is self-contained enough to be extracted for other deterministic workflow engines.
A separate Go module that implements a golangci-lint analyzer to statically reject non-deterministic workflow code (map iteration, time.Sleep, native channels). It is a reusable pattern for enforcing workflow determinism at compile time and can be adapted to other workflow systems.
A workflow testing harness that runs workflows without a real backend, with mocked activities and controllable time. It demonstrates a clean test-double pattern for event-sourced workflow engines and is reusable for any project needing deterministic workflow tests.
A small metrics client interface with no-op and performance implementations. It shows a clean way to abstract metrics collection behind an interface and is easily reusable across Go services.
State-machine driven command execution for workflow operations (schedule activity, timer, subworkflow, complete). The command pattern keeps workflow side effects explicit and replayable, and the state machine logic is isolated enough to be reused in other durable execution engines.