Build the safeguards
Eight explained steps, tradeoffs, pitfalls and a checkpoint before moving on.
Read the tutorialHow-to / First result to independent work
Start with the result you can see, then choose how far into the implementation you want to go.
Run one failure and one safeguarded version. Read tutorial Steps 1–4. Write down the input, the violated rule, the decision that enforces it, and the remaining limit. Keep that four-part explanation beside the code.
Show the canceled collector first. Explain who owns the queue, who closes it, how blocked work stops and why the function waits for workers. Separate concurrency safety from the delivery guarantee.
Download and extract the matching source. Begin with GETTING_STARTED.md. The included preview serves the prebuilt browser application on your own computer. Follow the eight tutorial steps, then run the native checks. The public source viewer is read-only; local source files are yours to edit.
python preview.py
# Open the loopback address printed by the preview.
# Stop the preview with Ctrl+C.Use the language-specific instructions below before rebuilding. Serve the application over HTTP; opening an HTML file directly does not provide the module and WebAssembly environment used by the preview.
# With Go 1.27:
cd src
go test ./...
go run ./cmd/server
# Native race checks additionally need a supported C compiler:
go test -race ./...Independent challenge
Add a bounded retry budget for a simulated transient error. Keep one logical message identity across attempts, preserve the worker limit, and make cancellation interrupt the retry delay.
Write the expected behavior before changing the implementation. Keep the original failure as a regression case. Explain the tradeoff you accepted and the result that would make you reconsider it.
The download includes a recording script, a test matrix and a revision record. Use captions and keep the code readable at the target viewing size.
References support the language and runtime concepts. The lesson, scenarios and explanations are original Zyel Lab material.
Keep exploring
Eight explained steps, tradeoffs, pitfalls and a checkpoint before moving on.
Read the tutorialChoose a pattern and an environment for the problem you actually have.
Compare approachesA beginner route, a local setup and an extension challenge.
Open the how-to guideLab discussion / Go Worker Lab
Ask about the code, compare an approach, or describe an edge case. Reader comments are reviewed before publication.
Code walkthrough
These short excerpts connect the lab’s behavior to its implementation. Each example links to the full tutorial step for its context, tradeoffs and checkpoint. Names and dependencies belong to that source; the excerpts are not standalone programs.
The safeguarded path creates a fixed number of workers and a queue whose capacity equals that count. A producer sends messages through the queue. When the queue fills, the producer waits, limiting how far it gets ahead. This is backpressure: the upstream workload must respect downstream capacity.
jobs := make(chan int, config.Workers)
for range config.Workers { /* start one worker */ }
Both the producer send and the worker receive are select operations that also observe ctx.Done. A worker waiting for its simulated downstream result has its own cancellation branch. It stops its timer and records an incomplete outcome before returning. The final join runs after those paths settle.
select {
case <-ctx.Done(): return
case jobs <- id:
}
Workers update the same counters. A mutex protects both updates and snapshots so measurements themselves do not introduce a data race. The live panel displays per-run started, completed, failed and peak values from the engine result. It does not treat process-wide goroutine counts as an exact measure of application leaks.
c.mu.Lock()
defer c.mu.Unlock()
c.active++
c.result.Started++