Pipelines & cancellation

Stages that plug together

A pipeline is a chain of stages, each a function that takes a receive-only channel and returns a receive-only channel. Values flow stage to stage, every stage running in its own goroutine, all working concurrently — stage 2 processes item 5 while stage 1 is already fetching item 6.

For PawWalk: generate raw GPS fixes, filter out the noise (accuracy too low), score each into a distance delta. Three stages, three goroutines, one flow. The signature that makes it composable is always the same: func stage(in <-chan int) <-chan int.