Closed vvfan closed 11 months ago
接口: AssumeRole 描述:
在使用sts client时,使用 AssumeRole 方法,获取结果 若 client 和 request 均未设置 readTimeout
则在 获取timeout 时,经过 getAPIMaxTimeout 方法 使用了 json.Unmarshal, 而 apiTimeouts 是个很大的string 在大量调用时,会造成很大的 alloc_space
以下代码:
client, err := sts.NewClientWithAccessKey(<RegionId>, <AccessKeyId>, <AccessKeySecret>) request := sts.CreateAssumeRoleRequest() request.Scheme = "https" request.RoleArn = <RoleArn> request.RoleSessionName = <BucketName> request.DurationSeconds = "3600" request.Policy = policy responseSts, err := client.AssumeRole(request) if err != nil { return stsResponse, err } ........... sdk/api_timeout.go func (client *Client) getTimeout(request requests.AcsRequest) (time.Duration, time.Duration) { readTimeout := defaultReadTimeout connectTimeout := defaultConnectTimeout reqReadTimeout := request.GetReadTimeout() reqConnectTimeout := request.GetConnectTimeout() if reqReadTimeout != 0*time.Millisecond { readTimeout = reqReadTimeout } else if client.readTimeout != 0*time.Millisecond { readTimeout = client.readTimeout } else if client.httpClient.Timeout != 0 { readTimeout = client.httpClient.Timeout } else if timeout, ok := getAPIMaxTimeout(request.GetProduct(), request.GetActionName()); ok { readTimeout = timeout } if reqConnectTimeout != 0*time.Millisecond { connectTimeout = reqConnectTimeout } else if client.connectTimeout != 0*time.Millisecond { connectTimeout = client.connectTimeout } return readTimeout, connectTimeout }
fixed by #596
接口: AssumeRole 描述:
在使用sts client时,使用 AssumeRole 方法,获取结果 若 client 和 request 均未设置 readTimeout
则在 获取timeout 时,经过 getAPIMaxTimeout 方法 使用了 json.Unmarshal, 而 apiTimeouts 是个很大的string 在大量调用时,会造成很大的 alloc_space
以下代码: