Skip to content

Commit 514ea1c

Browse files
committed
Few minor changes to the "contexts" section of the readme
1 parent 3acd02c commit 514ea1c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ all goroutines feeding the stream are allowed to complete.
232232

233233
Rill is context-agnostic, meaning that it does not enforce any specific context usage.
234234
However, it's recommended to make user-defined pipeline stages context-aware.
235-
This is especially important for the initial stage, as it allows to stop feeding the pipeline with new items when the context is canceled.
235+
This is especially important for the initial stage, as it allows to stop feeding the pipeline with new items after the context cancellation.
236236

237-
In the example below the `CheckAllUsersExist` function uses several concurrent workers to check if all users
238-
from the given list exist. The function returns as soon as it encounters a non-existent user.
239-
Such early return triggers the context cancellation, which in-turn stops all remaining users fetches.
237+
In the example below the `CheckAllUsersExist` function uses several concurrent workers to check if all users
238+
from the given list exist. When an error occurs (like a non-existent user), the function returns that error
239+
and cancels the context, which in turn stops all remaining user fetches.
240240

241241
[Try it](https://pkg.go.dev/github.com/destel/rill#example-package-Context)
242242
```go
@@ -254,6 +254,7 @@ func CheckAllUsersExist(ctx context.Context, concurrency int, ids []int) error {
254254
ctx, cancel := context.WithCancel(ctx)
255255
defer cancel()
256256

257+
// Convert the slice into a stream
257258
idsStream := rill.FromSlice(ids, nil)
258259

259260
// Fetch users concurrently.

example_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ func CheckAllUsersExist(ctx context.Context, concurrency int, ids []int) error {
318318
ctx, cancel := context.WithCancel(ctx)
319319
defer cancel()
320320

321+
// Convert the slice into a stream
321322
idsStream := rill.FromSlice(ids, nil)
322323

323324
// Fetch users concurrently.

0 commit comments

Comments
 (0)