From 507ba1606564cf061242be1d450c14277331c2be Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Wed, 21 Jul 2021 23:53:31 +0800 Subject: [PATCH] Fix: incorrect use batch --- adapter/provider/healthcheck.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adapter/provider/healthcheck.go b/adapter/provider/healthcheck.go index 636873d9..4d2711a5 100644 --- a/adapter/provider/healthcheck.go +++ b/adapter/provider/healthcheck.go @@ -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()