How indeedeng/iwf works
Project type and purpose
• This is a Go‐based long‐running workflow orchestration “server” component of the iWF framework.
• It exposes an HTTP API (using OpenAPI/Swagger) that client SDKs (Go/Java/Python) call to start, signal, query, or manage workflows.
• Under the hood, it uses Temporal (or Cadence) as the durable workflow engine, layering abstractions (durable timers, RPC, KV storage, retry policies) on top.
File structure
• cmd/server: entrypoint for the iWF server binary.
• config: configuration loading and dynamic config (YAML templates).
• service: core business logic—API HTTP handlers (service/api), client wrappers to Cadence/Temporal (service/client), common utilities (service/common), and interpreter orchestration (service/interpreter).
• gen/iwfidl & openapi-generator: auto‐generated client and API schema code.
• docker-compose & Dockerfile: deployment artifacts to bring up iWF server + Temporal/Cadence + dynamic‐config.
• integ & replayTests: end‐to‐end integration and replay test suites driving workflows via the public API.
README for additional insights
• iWF is an API orchestration platform providing a coding framework for durable timers, async execution, KV storage, RPC, message queues.
• It requires a server (this repo) and one of the SDKs to invoke the HTTP endpoints.
High‐level components
a. External Clients (SDKs):
– Golang, Java, Python SDKs invoking HTTP/JSON endpoints.
b. API Gateway / HTTP Layer (service/api + gen/iwfidl/api):
– Routers, OpenAPI handlers, request validation.
c. Service Layer (service/service.go + service/common + service/client):
– Business façade managing workflows—translating API calls into interpreter commands.
– Temporal/Cadence client adapters.
d. Interpreter Layer (service/interpreter):
– Core orchestration logic—state machine, durable timers, signal/RPC handling, continue‐as‐new, persistence, local vs. global versioning.
e. Workflow Worker Processes (temp/cadence workers):
– Registered workflow‐and‐activity providers that execute user code.
f. Backend Stateful Services:
– Temporal/Cadence cluster (gRPC endpoints)
– Dynamic Configuration Service (SQL‐backed)
– (Optional) Key‐Value storage if external.
g. Persistence & Metrics:
– Temporal’s internal DB, plus service/log for server logs and metrics output.
Relationships and interactions
• SDK → HTTP API → Service Layer → Interpreter
• Interpreter ↔ Cadence/Temporal Client → Temporal Server
• Interpreter schedules timers, local activities, signals via the Temporal SDK
• Dynamic config service consulted by interpreter/config for runtime tuning
• Integration tests invoke the HTTP API and validate end‐to‐end behavior, including replayTests using history files.
Architectural patterns & design principles
• Layered Architecture: clear separation among API, service façade, orchestration interpreter, external workflow engine.
• Dependency Injection via interfaces in service/client and interpreter/interfaces for pluggability (Cadence vs. Temporal).
• Code‐Generation: OpenAPI‐IDL for API schema (gen/iwfidl).
• Containerization/Microservice Deployment: Docker images for server, Temporal, dynamic‐config.
• Stateful vs. Stateless: server is stateless (reads config & dynamic‐config), state lives in Temporal.
Technologies, frameworks, and libraries
• Go modules (go.mod/go.sum)
• OpenAPI Generator (gen/iwfidl)
• Temporal (or Cadence) Go SDK
• Docker + Docker Compose
• YAML config + dynamic‐config SQL
• CI workflows (.github/workflows) for unit, integration, and E2E tests.
Elements
– From “SDK” to “HTTP API Layer” (REST calls)
– API → Service → Interpreter → Temporal gRPC → Temporal DB
– Interpreter ↔ Dynamic Config
– API layer in green
– Service & common utilities in blue
– Interpreter in orange
– External systems (Temporal, DB, dynamic config) in gray
– Rectangles for components