Fix: incorrect use batch

This commit is contained in:
gVisor bot 2021-07-21 23:53:31 +08:00
parent b29ea418cb
commit 4e38de95f2

View file

@ -59,14 +59,14 @@ func (hc *HealthCheck) touch() {
} }
func (hc *HealthCheck) check() { func (hc *HealthCheck) check() {
ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout) b := batch.New(batch.WithConcurrencyNum(10))
defer cancel()
b, ctx := batch.WithContext(ctx, batch.WithConcurrencyNum(10))
for _, proxy := range hc.proxies { for _, proxy := range hc.proxies {
p := proxy p := proxy
b.Go(p.Name(), func() (interface{}, error) { 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() b.Wait()