@@ -62,9 +62,8 @@ func (s *scheduler) run(sections chan uint64, dist chan *request, done chan []by
6262 pend := make (chan uint64 , cap (dist ))
6363
6464 // Start the pipeline schedulers to forward between user -> distributor -> user
65- wg .Add (2 )
66- go s .scheduleRequests (sections , dist , pend , quit , wg )
67- go s .scheduleDeliveries (pend , done , quit , wg )
65+ wg .Go (func () { s .scheduleRequests (sections , dist , pend , quit ) })
66+ wg .Go (func () { s .scheduleDeliveries (pend , done , quit ) })
6867}
6968
7069// reset cleans up any leftovers from previous runs. This is required before a
@@ -84,9 +83,8 @@ func (s *scheduler) reset() {
8483// scheduleRequests reads section retrieval requests from the input channel,
8584// deduplicates the stream and pushes unique retrieval tasks into the distribution
8685// channel for a database or network layer to honour.
87- func (s * scheduler ) scheduleRequests (reqs chan uint64 , dist chan * request , pend chan uint64 , quit chan struct {}, wg * sync. WaitGroup ) {
86+ func (s * scheduler ) scheduleRequests (reqs chan uint64 , dist chan * request , pend chan uint64 , quit chan struct {}) {
8887 // Clean up the goroutine and pipeline when done
89- defer wg .Done ()
9088 defer close (pend )
9189
9290 // Keep reading and scheduling section requests
@@ -131,9 +129,8 @@ func (s *scheduler) scheduleRequests(reqs chan uint64, dist chan *request, pend
131129
132130// scheduleDeliveries reads section acceptance notifications and waits for them
133131// to be delivered, pushing them into the output data buffer.
134- func (s * scheduler ) scheduleDeliveries (pend chan uint64 , done chan []byte , quit chan struct {}, wg * sync. WaitGroup ) {
132+ func (s * scheduler ) scheduleDeliveries (pend chan uint64 , done chan []byte , quit chan struct {}) {
135133 // Clean up the goroutine and pipeline when done
136- defer wg .Done ()
137134 defer close (done )
138135
139136 // Keep reading notifications and scheduling deliveries
0 commit comments