This commit is contained in:
laodaming 2023-09-22 12:05:05 +08:00
parent 0dcaf2ce09
commit 27ae48991c
2 changed files with 13 additions and 10 deletions

View File

@ -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())

View File

@ -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