November 2017
Intermediate to advanced
670 pages
17h 35m
English
After the Job struct definition comes the displayProgress method:
func (b *Job) displayProgress(stopChan chan struct{}) { var prevResponseCount int for { select { case <-time.Tick(time.Millisecond * 500): responseCount := len(b.responseChan) if prevResponseCount < responseCount { prevResponseCount = responseCount Debug.Printf("> %d requests done.", responseCount) } case <-stopChan: return } }}
Every 500 milliseconds, displayProgress checks to see whether a new response has been processed. It does this by checking the size of the job's response channel. If it finds a new response, it prints out a line like the following:
DEBUG : 2017/05/17 19:04:36 requestor.go:38: > 3 requests done.
It will continue to loop until ...