Skip to content

Commit ae99d19

Browse files
committed
fix: doc test errors
1 parent 3ba0cef commit ae99d19

5 files changed

+25
-27
lines changed

README.md

+21-23
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ If you have another common use case you would like to see covered by this packag
1111

1212
## Cookbook
1313

14-
* [How to run a pipeline until the container is killed](https://github.com/deliveryhero/pipeline#PipelineShutsDownWhenContainerIsKilled)
15-
* [How to shut down a pipeline when there is a error](https://github.com/deliveryhero/pipeline#PipelineShutsDownOnError)
16-
* [How to shut down a pipeline after it has finished processing a batch of data](https://github.com/deliveryhero/pipeline#PipelineShutsDownWhenInputChannelIsClosed)
14+
* [How to run a pipeline until the container is killed](https://github.com/deliveryhero/pipeline#pipelineshutsdownwhencontaineriskilled)
15+
* [How to shut down a pipeline when there is a error](https://github.com/deliveryhero/pipeline#pipelineshutsdownonerror)
16+
* [How to shut down a pipeline after it has finished processing a batch of data](https://github.com/deliveryhero/pipeline#pipelineshutsdownwheninputchannelisclosed)
1717

1818
## Functions
1919

@@ -232,6 +232,7 @@ ProcessBatchConcurrently fans the in channel out to multiple batch Processors ru
232232
then it fans the out channels of the batch Processors back into a single out chan
233233

234234
```golang
235+
235236
// Create a context that times out after 5 seconds
236237
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
237238
defer cancel()
@@ -253,19 +254,17 @@ p = pipeline.ProcessBatchConcurrently(ctx, 2, 2, time.Minute, pipeline.NewProces
253254
for result := range p {
254255
fmt.Printf("result: %d\n", result)
255256
}
256-
```
257257

258-
Output:
258+
// Example Output:
259+
// result: 1
260+
// result: 2
261+
// result: 3
262+
// result: 5
263+
// error: could not process [7 8], context deadline exceeded
264+
// error: could not process [4 6], context deadline exceeded
265+
// error: could not process [9], context deadline exceeded
259266

260267
```
261-
result: 1
262-
result: 2
263-
result: 3
264-
result: 5
265-
error: could not process [7 8], context deadline exceeded
266-
error: could not process [4 6], context deadline exceeded
267-
error: could not process [9], context deadline exceeded
268-
```
269268

270269
### func [ProcessConcurrently](/process.go#L26)
271270

@@ -275,6 +274,7 @@ ProcessConcurrently fans the in channel out to multiple Processors running concu
275274
then it fans the out channels of the Processors back into a single out chan
276275

277276
```golang
277+
278278
// Create a context that times out after 5 seconds
279279
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
280280
defer cancel()
@@ -296,19 +296,17 @@ p = pipeline.ProcessConcurrently(ctx, 2, pipeline.NewProcessor(func(ctx context.
296296
for result := range p {
297297
log.Printf("result: %d\n", result)
298298
}
299-
```
300299

301-
Output:
300+
// Example Output:
301+
// result: 2
302+
// result: 1
303+
// result: 4
304+
// result: 3
305+
// error: could not process 6, process was canceled
306+
// error: could not process 5, process was canceled
307+
// error: could not process 7, context deadline exceeded
302308

303309
```
304-
result: 2
305-
result: 1
306-
result: 4
307-
result: 3
308-
error: could not process 6, process was canceled
309-
error: could not process 5, process was canceled
310-
error: could not process 7, context deadline exceeded
311-
```
312310

313311
### func [Split](/split.go#L4)
314312

cancel_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestCancel(t *testing.T) {
4141
// Start canceling the pipeline about half way through the test
4242
ctx, cancel := context.WithTimeout(context.Background(), testDuration/2)
4343
defer cancel()
44-
for i := range Cancel[int](ctx, canceled, in) {
44+
for i := range Cancel(ctx, canceled, in) {
4545
logf("%d", i)
4646
}
4747

collect_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestCollect(t *testing.T) {
124124
defer cancel()
125125

126126
// Collect responses
127-
collect := Collect[int](ctx, test.args.maxSize, test.args.maxDuration, in)
127+
collect := Collect(ctx, test.args.maxSize, test.args.maxDuration, in)
128128
timeout := time.After(maxTestDuration)
129129
var outs [][]int
130130
var isOpen bool

process_batch_example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func ExampleProcessBatchConcurrently() {
6161
fmt.Printf("result: %d\n", result)
6262
}
6363

64-
// Output:
64+
// Example Output:
6565
// result: 1
6666
// result: 2
6767
// result: 3

process_example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func ExampleProcessConcurrently() {
6161
log.Printf("result: %d\n", result)
6262
}
6363

64-
// Output:
64+
// Example Output:
6565
// result: 2
6666
// result: 1
6767
// result: 4

0 commit comments

Comments
 (0)