Closed Yw-melo closed 5 months ago
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
After the client calls, the selector peer cannot be obtained through
selector.FromPeerContext
. It is found that the following two lines cover the peerKey. In this case, the peer can only be obtained in the source code and cannot be obtained after the client calls. https://github.com/go-kratos/kratos/blob/85740b179b097d3ba63ff873819bfc1d8ab28899/transport/http/client.go#L272-L273
Would it be better to go to new when there is no peerKey, so that you can get the peer through newPeer -> client call -> fromPeer
_, ok := selector.FromPeerContext(ctx)
if !ok {
var p selector.Peer
ctx = selector.NewPeerContext(ctx, &p)
}
🤖
你好 @Yw-melo! 😊 我是Dosu,一个可以帮助你解决问题、回答疑问,甚至成为贡献者的机器人。我在这里为你提供帮助,直到人类的维护者能够接手。我正在看你的问题,我会尽快给你一个完整的答案。一起来解决问题吧! 🚀
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
🤖
Hello @Yw-melo! 😊 I am Dosu, a bot that can help you solve problems, answer questions, and even become a contributor. I'm here to assist you until human defenders can take over. I'm looking at your question and I'll give you a complete answer as soon as possible. Let’s solve the problem together! 🚀
Hi, @Yw-melo
I'm helping the Kratos team manage their backlog and am marking this issue as stale. From what I understand, the issue was related to the inability to retrieve the selector peer using selector.FromPeerContext
after a client call due to the peerKey being overwritten in the code. The suggestion was to modify the code to avoid overwriting the peerKey, which would allow for retrieving the peer after a client call. The issue has been resolved by modifying the code to avoid overwriting the peerKey, which now allows for retrieving the peer using selector.FromPeerContext
after a client call. Assistance was provided by me.
Could you please confirm if this issue is still relevant to the latest version of the Kratos repository? If it is, please let the Kratos team know by commenting on the issue. Otherwise, feel free to close the issue yourself or the issue will be automatically closed in 7 days.
Thank you!
客户端调用后无法通过
selector.FromPeerContext
拿到 selector peer,发现是下面两行覆盖了peerKey,这样的话只能在源码中拿到peer,无法在客户端调用后拿到 https://github.com/go-kratos/kratos/blob/85740b179b097d3ba63ff873819bfc1d8ab28899/transport/http/client.go#L272-L273如果改成没有peerKey的时候在去new会不会好些,这样经过 newPeer ->客户端调用->fromPeer即可拿到peer