A producer is the first stage of a concurrent pipeline: it creates or relays messages and delivers them through an output channel to the next stage. In the HTTP client pipeline, it separates request generation from throttling, dispatching, and result collection. section 6.6.2 section 6.7.1
A Go producer stage typically follows these rules:
- Accepts the number of messages and the request to relay, but no input channel. section 6.7.1
- Creates an output channel and launches a goroutine so the function returns without waiting. section 6.7.1
- Sends each message the configured number of times, then closes the channel. section 6.7
- Returns a receive-only channel, clarifying that downstream stages may receive but cannot send. section 6.7.1
Relaying HTTP requests
func produce(n int, req *http.Request) <-chan *http.Request { out := make(chan *http.Request) go func() { defer close(out) for range n { out <- req } }() return out } A pipeline coordinator can connect the result directly to the next stage: requests := produce(n, req). section 6.7.1 section 6.7.2
Figure 6.3 SendN runs the pipeline and returns a Results iterator. Stages run concurrently and are connected through channels. Dispatcher goroutines call the configured Send function to send concurrent HTTP requests and return results.
Trace how the producer connects concurrent pipeline stages through channels and ultimately feeds results to an iterator. section 6.6.2







