From 27ae48991c184949fed50e27e24db9c7ecc8cac2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 12:05:05 +0800 Subject: [PATCH] fix --- service/repositories/image_handle.go | 5 +++-- utils/curl/client_resty.go | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index acf1f0c2..7fbe4806 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -316,8 +316,9 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq var resultBLM constants.BLMServiceUrlResult err = curl.NewClient(ctx, &curl.Config{ - BaseUrl: *l.BLMServiceUrl, - Url: constants.BLMServiceUrlLogoCombine, + BaseUrl: *l.BLMServiceUrl, + Url: constants.BLMServiceUrlLogoCombine, + RequireTimeout: time.Second * 15, }).PostJson(postMap, &resultBLM) logc.Infof(ctx, "合图--算法请求--合图--结束时间:%v", time.Now().UTC()) diff --git a/utils/curl/client_resty.go b/utils/curl/client_resty.go index 3221f4ec..abbfd46f 100644 --- a/utils/curl/client_resty.go +++ b/utils/curl/client_resty.go @@ -19,9 +19,10 @@ func NewClient(ctx context.Context, c *Config) Client { // 创建一个restry客户端 client := resty.New().SetBaseURL(c.BaseUrl) - // 设置超时时间为 1 分钟 - client.SetTimeout(1 * time.Minute) - + // 设置超时时间为 5 分钟 + if c.RequireTimeout == 0 { + client.SetTimeout(5 * time.Minute) + } /* 传输链路 */ tracer := otel.GetTracerProvider().Tracer(trace.TraceName) spanCtx, span := tracer.Start( @@ -60,11 +61,12 @@ func NewClient(ctx context.Context, c *Config) Client { type ( Config struct { - BaseUrl string `json:"base_url"` - Url string `json:"url"` - HeaderData map[string]string `json:"header_data"` - RetryCount int64 `json:"retry_count"` - RetryWaitTime int64 `json:"retry_wait_time"` + BaseUrl string `json:"base_url"` + Url string `json:"url"` + HeaderData map[string]string `json:"header_data"` + RetryCount int64 `json:"retry_count"` + RetryWaitTime int64 `json:"retry_wait_time"` + RequireTimeout time.Duration `json:"require_timeout"` } defaultClient struct { c *Config