Fix: incorrect use batch

This commit is contained in:
Dreamacro 2021-07-21 23:53:31 +08:00
parent aa9f8a39a3
commit 507ba16065

View file

@ -59,14 +59,14 @@ func (hc *HealthCheck) touch() {
}
func (hc *HealthCheck) check() {
ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout)
defer cancel()
b, ctx := batch.WithContext(ctx, batch.WithConcurrencyNum(10))
b := batch.New(batch.WithConcurrencyNum(10))
for _, proxy := range hc.proxies {
p := proxy
b.Go(p.Name(), func() (interface{}, error) {
return p.URLTest(ctx, hc.url)
ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout)
defer cancel()
p.URLTest(ctx, hc.url)
return nil, nil
})
}
b.Wait()