MCPcopy Create free account
hub / github.com/cloudwego/eino-examples / runBasicSequential

Function runBasicSequential

compose/batch/main.go:175–198  ·  view source on GitHub ↗

Scenario 1: Basic Sequential Processing Demonstrates: MaxConcurrency=0 for sequential execution

(ctx context.Context)

Source from the content-addressed store, hash-verified

173// Scenario 1: Basic Sequential Processing
174// Demonstrates: MaxConcurrency=0 for sequential execution
175func runBasicSequential(ctx context.Context) {
176 docs := createSampleDocuments(3)
177 workflow := createSimpleReviewWorkflow()
178
179 batchNode := batch.NewBatchNode(&batch.NodeConfig[ReviewRequest, ReviewResult]{
180 Name: "SequentialReviewer",
181 InnerTask: workflow,
182 MaxConcurrency: 0, // Sequential: process one at a time
183 })
184
185 start := time.Now()
186 results, err := batchNode.Invoke(ctx, docs)
187 elapsed := time.Since(start)
188
189 if err != nil {
190 fmt.Printf("Error: %v\n", err)
191 return
192 }
193
194 fmt.Printf("Processed %d documents sequentially in %v\n", len(results), elapsed)
195 for _, r := range results {
196 fmt.Printf(" - %s: approved=%v, score=%.2f\n", r.DocumentID, r.Approved, r.Score)
197 }
198}
199
200// Scenario 2: Concurrent Processing
201// Demonstrates: MaxConcurrency>0 for parallel execution with limit

Callers 1

mainFunction · 0.85

Calls 5

NewBatchNodeFunction · 0.92
createSampleDocumentsFunction · 0.85
PrintfMethod · 0.65
InvokeMethod · 0.45

Tested by

no test coverage detected