Generated: 2025-11-24 Module: github.com/sicko7947/gorkflow Go Version: 1.25.3
gorkflow/
├── builder/ # Fluent workflow builder API
│ ├── builder.go
│ ├── builder_test.go
│ ├── options.go
│ └── validation.go
├── engine/ # Workflow execution engine
│ ├── engine.go
│ ├── engine_integration_test.go
│ ├── executor.go
│ ├── traverser.go
│ ├── backoff.go
│ ├── retry_test.go
│ └── conditional_test.go
├── store/ # Persistence layer
│ ├── store.go
│ ├── schema.go
│ ├── schema_test.go
│ ├── memory.go
│ └── memory_test.go
├── example/ # Complete working example
│ ├── workflow.go
│ ├── steps.go
│ ├── orchestrator.go
│ ├── types.go
│ └── GUIDE.md
├── workflow.go # Core workflow definition
├── step.go # Step definition & execution
├── graph.go # Execution graph (DAG)
├── models.go # Data models
├── config.go # Configuration types
├── context.go # Execution context
├── errors.go # Error handling
├── helpers.go # Utility functions
├── logging.go # Logging utilities
├── store_interface.go # Store interface
└── README.md # Main documentation
- Package:
workflow(root) - Purpose: Core workflow engine and types
- Key Functions:
NewStep[TIn, TOut]()- Create type-safe workflow stepsNewWorkflowInstance()- Create workflow instance
- Package:
builder - Entry:
builder.NewWorkflow() - Purpose: Fluent API for constructing workflows
- Pattern: Builder pattern with method chaining
- Package:
engine - Entry:
engine.NewEngine() - Purpose: Orchestrate workflow execution
- Key Methods:
StartWorkflow()- Begin workflow executionGetRun()- Retrieve workflow statusCancel()- Cancel running workflow
- Package:
store - Implementations:
NewMemoryStore()- In-memory storage
- Package:
simple_math(example) - Entry:
NewSimpleMathWorkflow() - Purpose: Complete reference implementation
- See:
example/GUIDE.md
Files: workflow.go, step.go, graph.go
Exports:
type Workflow- Workflow blueprinttype Step[TIn, TOut]- Generic step definitiontype ExecutionGraph- DAG representationNewWorkflowInstance()- Create workflowNewStep[TIn, TOut]()- Create typed step
Purpose: Define workflow structure, steps, and execution graph
Files: builder/builder.go, builder/options.go, builder/validation.go
Exports:
type WorkflowBuilder- Fluent builderNewWorkflow()- Start buildingWithDescription(),WithVersion(),WithConfig()- ConfigurationSequence()- Chain steps sequentiallyParallel()- Execute steps in parallelThenStep()- Add single stepBuild()- Finalize workflow
Purpose: Fluent API for constructing complex workflows
Files: engine/engine.go, engine/executor.go, engine/traverser.go
Exports:
type Engine- Execution orchestratortype EngineConfig- Engine configurationNewEngine()- Create engineStartWorkflow()- Begin executionGetRun()- Query workflow statusGetStepExecutions()- Get step detailsCancel()- Cancel workflow
Purpose: Execute workflows, manage retries, handle state transitions
Files: engine/backoff.go
Exports:
type BackoffStrategy- Backoff algorithmBackoffLinear,BackoffExponential,BackoffNone- Strategies- Backoff calculation logic
Purpose: Implement retry policies with configurable backoff
Files: engine/traverser.go
Exports:
type GraphTraverser- Graph traversal logicGetExecutionOrder()- Topological sort- Dependency resolution
Purpose: Determine execution order from DAG
Files: store/store.go, store/schema.go
Exports:
type WorkflowStoreinterfaceCreateRun(),UpdateRun(),GetRun()CreateStepExecution(),UpdateStepExecution(),GetStepExecutions()SetState(),GetState(),DeleteState()
Purpose: Abstraction for workflow state persistence
Files: store/memory.go
Exports:
type MemoryStore- In-memory implementationNewMemoryStore()- Create store
Purpose: Fast in-memory storage for development and testing
Files: models.go
Exports:
type WorkflowRun- Workflow execution recordtype StepExecution- Step execution recordtype RunStatus- Workflow status enumtype StepStatus- Step status enumtype TriggerInfo- Workflow trigger metadatatype WorkflowError- Error information
Purpose: Core data structures for workflow state
Files: config.go
Exports:
type ExecutionConfig- Step/workflow configurationtype BackoffStrategy- Retry backoff typestype StepOption- Functional optionsWithRetries(),WithBackoff(),WithTimeout()- Option constructorsDefaultExecutionConfig,DefaultEngineConfig- Defaults
Purpose: Configuration types and functional options
Files: context.go
Exports:
type StepContext- Step execution contexttype StepOutputAccessor- Access previous step outputstype StateAccessor- Access workflow state- Context creation and management
Purpose: Provide execution context to step handlers
Files: errors.go
Exports:
type WorkflowError- Workflow-specific errors- Error classification and formatting
- Retry-related error types
Purpose: Structured error handling
Not required for library usage. Configuration via code.
go.mod- Module dependenciesgo.sum- Dependency checksums
README.md- Comprehensive guide with examplesexample/GUIDE.md- Step-by-step example walkthroughPROJECT_INDEX.md- This file (repository index)
*_test.gofiles throughout codebase- Builder tests:
builder/builder_test.go - Store tests:
store/memory_test.go,store/schema_test.go - Retry tests:
engine/retry_test.go - Conditional tests:
engine/conditional_test.go
- Engine integration:
engine/engine_integration_test.go
# All tests
go test ./...
# With coverage
go test -cover ./...
# Integration tests only
go test -tags=integration ./store/...- google/uuid (v1.6.0) - UUID generation for run IDs
- rs/zerolog (v1.34.0) - Structured logging
- stretchr/testify (v1.11.1) - Testing assertions
- Requires Go 1.21+ (uses generics)
go get github.com/sicko7947/gorkflowimport (
workflow "github.com/sicko7947/gorkflow"
"github.com/sicko7947/gorkflow"
"github.com/sicko7947/gorkflow/engine"
"github.com/sicko7947/gorkflow/store"
)
// Define step
step := workflow.NewStep(
"hello",
"Say Hello",
func(ctx *workflow.StepContext, input string) (string, error) {
return "Hello, " + input, nil
},
)
// Build workflow
wf, _ := builder.NewWorkflow("greeting", "Greeting Workflow").
Sequence(step).
Build()
// Execute
store := store.NewMemoryStore()
logger := zerolog.New(os.Stdout)
eng := engine.NewEngine(store, logger, engine.DefaultEngineConfig)
runID, _ := eng.StartWorkflow(context.Background(), wf, "World")cd example/
cat GUIDE.mdChain steps that depend on previous outputs
Execute independent steps concurrently
Transform data through multiple stages
Extract, transform, and load data with retries
Coordinate multiple services or operations
Implement complex state transitions
- Generic step definitions:
Step[TIn, TOut] - Compile-time type checking
- Automatic marshaling/unmarshaling
- Directed Acyclic Graph representation
- Topological sorting for execution order
- Cycle detection and validation
- Configurable retry policies
- Linear and exponential backoff
- Per-step timeout support
- Pluggable store interface
- In-memory for development
- LibSQL for persistence
- Structured logging (zerolog)
- Progress tracking (0.0 to 1.0)
- Step execution history
- Total Go Files: 34
- Core Packages: 4 (root, builder, engine, store)
- Store Implementations: 2 (Memory, LibSQL)
- Test Files: 9
- Example Files: 5
- Documentation: 3 files
1. Define Steps → NewStep[TIn, TOut]()
2. Build Workflow → builder.NewWorkflow().Sequence(...).Build()
3. Create Engine → engine.NewEngine(store, logger, config)
4. Start Execution → engine.StartWorkflow(ctx, wf, input)
5. Monitor Progress → engine.GetRun(ctx, runID)
6. Complete/Fail → Automatic state transitions
PENDING- Created, not startedRUNNING- Currently executingCOMPLETED- Successfully finishedFAILED- Execution failedCANCELLED- Manually cancelled
PENDING- Queued for executionRUNNING- Currently executingCOMPLETED- Successfully finishedFAILED- Execution failedSKIPPED- Skipped due to conditionsRETRYING- In retry loop
- Main README: Comprehensive usage guide
- Example Guide: Step-by-step tutorial
example/directory: Complete working implementation*_test.gofiles: Usage patterns and edge cases
Index Version: 1.0 Last Updated: 2025-11-24 Maintainer: sicko7947