November 2017
Intermediate to advanced
670 pages
17h 35m
English
We use three channels to manage the life cycle of our requestor component:
Every 5,000 milliseconds, we check responseChan to see whether we've received a new response. If so, we print a message indicating that the request is completed.
First, stopChan is used to stop the running of the displayProgress function.
Then, interruptChan is used to signal everything to shut down when the user presses Ctrl + C.
The Run method of Job makes all the requests, displays summary results, and blocks until all responses are received:
func (j *Job) Run() { j.responseChan = make(chan *response, j.NumRequests) stopChan := make( ...