From c79dc78fc9433d8a82fa04bbc347c1d96eba178c Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Thu, 11 Aug 2022 10:10:39 +0800 Subject: [PATCH] fix lint --- client/dtmcli/dtmimp/vars.go | 4 ++++ client/dtmcli/types.go | 1 + 2 files changed, 5 insertions(+) diff --git a/client/dtmcli/dtmimp/vars.go b/client/dtmcli/dtmimp/vars.go index 7ac6918..6395f1c 100644 --- a/client/dtmcli/dtmimp/vars.go +++ b/client/dtmcli/dtmimp/vars.go @@ -40,10 +40,14 @@ var BarrierTableName = "dtm_barrier.barrier" var restyClients sync.Map +// GetRestyClient2 will return a resty client with timeout set func GetRestyClient2(timeout time.Duration) *resty.Client { cli, ok := restyClients.Load(timeout) if !ok { client := resty.New() + if timeout != 0 { + client.SetTimeout(timeout) + } AddRestyMiddlewares(client) restyClients.Store(timeout, client) cli = client diff --git a/client/dtmcli/types.go b/client/dtmcli/types.go index 48aa77b..7a0b4b4 100644 --- a/client/dtmcli/types.go +++ b/client/dtmcli/types.go @@ -42,6 +42,7 @@ func GetRestyClient() *resty.Client { return dtmimp.GetRestyClient2(0) } +// GetRestyClient2 get the resty.Client with the specified timeout set func GetRestyClient2(timeout time.Duration) *resty.Client { return dtmimp.GetRestyClient2(timeout) }