createSimpleReviewWorkflow creates a basic document review workflow that simulates automated review with random scoring
()
| 148 | // createSimpleReviewWorkflow creates a basic document review workflow |
| 149 | // that simulates automated review with random scoring |
| 150 | func createSimpleReviewWorkflow() *compose.Workflow[ReviewRequest, ReviewResult] { |
| 151 | workflow := compose.NewWorkflow[ReviewRequest, ReviewResult]() |
| 152 | |
| 153 | workflow.AddLambdaNode("analyze", compose.InvokableLambda(func(ctx context.Context, req ReviewRequest) (ReviewResult, error) { |
| 154 | time.Sleep(50 * time.Millisecond) // Simulate processing time |
| 155 | |
| 156 | score := 0.5 + rand.Float64()*0.5 |
| 157 | approved := score >= 0.7 |
| 158 | |
| 159 | return ReviewResult{ |
| 160 | DocumentID: req.DocumentID, |
| 161 | Approved: approved, |
| 162 | Score: score, |
| 163 | Comments: fmt.Sprintf("Auto-reviewed document %s with priority %s", req.DocumentID, req.Priority), |
| 164 | ReviewedAt: time.Now(), |
| 165 | }, nil |
| 166 | })).AddInput(compose.START) |
| 167 | |
| 168 | workflow.End().AddInput("analyze") |
| 169 | |
| 170 | return workflow |
| 171 | } |
| 172 | |
| 173 | // Scenario 1: Basic Sequential Processing |
| 174 | // Demonstrates: MaxConcurrency=0 for sequential execution |
no outgoing calls
no test coverage detected