# Go Service Resilience Lab

By Chason Arthur
Revision 138.057
Published/updated 2026-11-04

## Start without installing dependencies

Extract this complete ZIP into a new folder. With Python 3 installed, run `python preview.py` from the extracted root. Open http://127.0.0.1:4210/. Stop with Ctrl+C. The prebuilt site is self-contained and makes no automatic external requests. Written reference links are optional. Do not open the files directly with file:// because workers and Wasm need HTTP.

## Run the native exercise

```sh
cd src/go
go test ./...
go run ./cmd/server
```

The gateway listens on 127.0.0.1:4197 and its real HTTP dependency on 127.0.0.1:4198. POST /run with {"preset":"slow","variant":"safe"}. Other presets are overload and recovery; variants are broken and safe. Ctrl+C stops both listeners. Run go test -race ./... separately when a supported C compiler is available; race instrumentation was not run in the authoring environment.

## Expected result

The safe implementation allows at most three dependency calls in flight and returns with zero active calls. Recovery eventually permits successful probes. Shed requests are counted separately from work that started and failed.

## Scope

Actual Go runs as WebAssembly with timed in-process dependency calls. The native download uses real loopback HTTP. These fixtures show control flow and cleanup; they are not a multicore benchmark, a network-fault simulator or a production capacity result.

## Change and rebuild

Node/browser packages: `npm ci`, `npm run rebuild`, then `python preview.py`. Go: edit src/go, run its tests and `python rebuild_wasm.py` before refreshing source. Python: edit src/python/engine.py and run `python refresh_source.py`. Rebuild keeps the local preview and source viewer aligned. FILE_MANIFEST.json describes the initial extracted package, not later edits. The source-map and source viewer manifest record the exact teaching files. Update edition/date metadata before publishing an edited version.

## Extension

Add a retryable 429 response with a bounded Retry-After value and a nonretryable 400 response. Keep retries within the original request deadline. Then move the dependency into a separate process and compare cancellation behavior.

Original teaching code and lessons are MIT-licensed. See THIRD_PARTY_NOTICES.md and licenses/. The package starts no production API, model, payment, email or cloud service.
