$ show cadence-workflow/cadence
Cadence is a production-grade distributed workflow orchestration engine written in Go. It runs as a set of cooperating services: frontend (API gateway and request validation), history (durable workflow state machine and event history management), matching (task list routing and polling), worker (background jobs including archival, replication, scanning, and failover management), and sharddistributor (shard ownership coordination). Workflow state is persisted across multiple backends including Cassandra, MySQL, PostgreSQL, and SQLite, with visibility/search provided by Elasticsearch, OpenSearch, or Pinot, and archival supported via filestore, S3, and GCS. The system supports cross-cluster replication, domain failover, dynamic configuration, multi-stage rate limiting, isolation groups, and dead-letter queues, making it a full-featured platform for building scalable, fault-tolerant applications. Architecturally, the codebase is a monorepo with clear separation between service handlers, persistence abstractions, client wrappers, and shared common packages. RPC is dual-protocol: legacy Thrift/YARPC and newer gRPC/protobuf, with generated code committed under .gen/. Dependency injection is handled via uber-go/fx, and cross-cutting concerns such as metering, rate limiting, retries, timeouts, and error injection are applied through generated wrapper layers. The primary entry points are cmd/server/main.go for the server, cmd/tools/cli/main.go for the admin CLI, cmd/canary/main.go for health canaries, and cmd/bench/main.go for load testing. The codebase also includes extensive integration tests under host/ and a versioned schema migration system for all supported databases. Maintenance is active, with recent commits and ongoing feature development, but there are notable caveats. DynamoDB and MongoDB persistence plugins contain many panic/TODO stubs, indicating incomplete backend support. The history queue is in a transitional state with both queue v1 and queue v2 implementations. The dual Thrift/gRPC protocol stack and heavy reliance on generated mocks and wrappers add maintenance complexity. Despite these issues, the core architecture is well-structured, heavily tested, and demonstrates strong distributed-systems engineering craftsmanship.
The LLM identified 5 files worth highlighting for reuse:
Parses cron expressions and computes next execution times with configurable overlap policies. Isolated utility that can be extracted for any scheduling or retry system needing cron-based backoff calculation.
Insertion-ordered map implementation with a concurrent variant. Provides deterministic iteration order while maintaining O(1) lookups, useful for caches, queues, and stateful collections in any Go project.
Multi-stage rate limiter that reserves capacity across hierarchical stages (e.g., global, domain, task-list) and defers usage accounting. Demonstrates a reusable pattern for distributed quota enforcement beyond Cadence's specific domain.
Generic pagination iterator and writer built on fetch/write callbacks. Used by reconciliation and blobstore components, but designed generically enough to be extracted for any paginated data processing pipeline.
Event-driven timer gate that supports manual time advancement, enabling deterministic testing of time-dependent code without real sleeps. A clean abstraction for injecting controllable time into concurrent systems.