Skip to content

Commit b5d7778

Browse files
author
“Kevin”
committed
Add readme file for batch sample
Signed-off-by: “Kevin” <“[email protected]”>
1 parent dfead9c commit b5d7778

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

cmd/samples/batch/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Batch Processing Sample
2+
3+
This sample demonstrates how to process large batches of tasks with controlled concurrency using Cadence's `x.NewBatchFuture` functionality.
4+
5+
## What it does
6+
7+
- Creates a configurable number of activities (default: 10)
8+
- Executes them with controlled concurrency (default: 3)
9+
- Simulates work with random delays (900-999ms per task)
10+
- Handles cancellation gracefully
11+
12+
## Real-world use cases
13+
14+
- Batch data processing
15+
- Bulk operations
16+
- ETL jobs
17+
- Report generation
18+
- File processing
19+
20+
## How to run
21+
22+
Start Worker:
23+
```bash
24+
./bin/batch -m worker
25+
```
26+
27+
Start Workflow:
28+
```bash
29+
./bin/batch -m trigger
30+
```
31+
32+
## Key concepts
33+
34+
- **Batch processing**: Process multiple tasks efficiently
35+
- **Concurrency control**: Limit simultaneous executions
36+
- **Activity factories**: Lazy evaluation of activities
37+
- **Future-based execution**: Asynchronous task management
38+
- **Context cancellation**: Graceful handling of timeouts

cmd/samples/batch/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func startWorkflow(h *common.SampleHelper) {
3535

3636
// Default batch configuration
3737
input := BatchWorkflowInput{
38-
Concurrency: 2,
38+
Concurrency: 3,
3939
TotalSize: 10,
4040
}
4141

0 commit comments

Comments
 (0)