Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github.com/alibabacloud-go/darabonba-openapi/v2/client *Client.GetRpcHeaders 为啥要去改client.Headers #68

Open
serious-snow opened this issue Mar 29, 2024 · 3 comments

Comments

@serious-snow
Copy link

/**
 * get RPC header for debug
 */
func (client *Client) GetRpcHeaders() (_result map[string]*string, _err error) {
	headers := client.Headers
	client.Headers = nil
	_result = headers
	return _result, _err
}

@yndu13
Copy link
Contributor

yndu13 commented May 21, 2024

设计上是这样子的,SetRpcHeaders和GetRpcHeaders是一次性的,也就是SetRpcHeaders后,仅在当前 request 中生效,下次 request 已清空。

如果您需要设置全局 headers,可以使用Config.GlobalParameters.Headers配置;
或者想要更好地 request 级别 headers 的隔离体验,可以使用util.RuntimeOptions.ExtendsParameters.Headers配置。

@yndu13
Copy link
Contributor

yndu13 commented May 21, 2024

我们将SetRpcHeaders方法和GetRpcHeaders方法置为Deprecated

@serious-snow
Copy link
Author

serious-snow commented May 21, 2024

你好, 我不是要用这个方法,我是想实例化一个client *alidns.Client,然后其它请求都用这个client, 应该会并发用这个client。
image
image

DoRPCRequest 会调用 GetRpcHeaders, 然后代码看逻辑来讲 可能会出现数据竞争,虽然这里 client.Headers 应该都是nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants