fix 修改重试逻辑

This commit is contained in:
timerzz 2024-07-26 14:59:32 +08:00
parent 2ec2db45d8
commit 597cccf7fa

View File

@ -3,14 +3,15 @@ package coach_client
import ( import (
"context" "context"
"fmt" "fmt"
"log/slog"
"net/url"
"time"
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy" "gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
restry_pool "gitea.timerzz.com/kedaya_haitao/common/pkg/restry-pool" restry_pool "gitea.timerzz.com/kedaya_haitao/common/pkg/restry-pool"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
"github.com/pkg/errors" "github.com/pkg/errors"
proxy2 "github.com/timerzz/proxypool/pkg/proxy" proxy2 "github.com/timerzz/proxypool/pkg/proxy"
"log/slog"
"net/url"
"time"
) )
type US struct { type US struct {
@ -36,7 +37,10 @@ func tryRequest(ctx context.Context, urlPath string, respData any, proxyGetter f
default: default:
} }
_, err := callByProxy(ctx, p, urlPath, respData) resp, err := callByProxy(ctx, p, urlPath, respData)
if resp.StatusCode() != 200 {
err = fmt.Errorf("请求错误:%d, %s", resp.StatusCode(), resp.Body())
}
if err != nil { if err != nil {
slog.Debug(err.Error()) slog.Debug(err.Error())
continue continue