You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "altman08 (via GitHub)" <gi...@apache.org> on 2026/01/07 08:22:43 UTC
[PR] surpport tag for selective channel (brpc)
altman08 opened a new pull request, #3189:
URL: https://github.com/apache/brpc/pull/3189
### What problem does this PR solve?
Issue Number: resolve
Problem Summary: To support tags for SelectiveChannel due to the requirements of the loadbalance plugin.
### What is changed and the side effects?
Changed:
Side effects:
- Performance effects:
- Breaking backward compatibility:
---
### Check List:
- Please make sure your changes are compilable.
- When providing us with a new feature, it is best to add related tests.
- Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3189:
URL: https://github.com/apache/brpc/pull/3189#discussion_r2670682065
##########
src/brpc/selective_channel.cpp:
##########
@@ -340,7 +339,7 @@ int Sender::IssueRPC(int64_t start_realtime_us) {
// Forward request attachment to the subcall
sub_cntl->request_attachment().append(_main_cntl->request_attachment());
sub_cntl->http_request() = _main_cntl->http_request();
-
+
Review Comment:
This line contains trailing whitespace at the end. Consider removing the trailing spaces to maintain code cleanliness.
```suggestion
```
##########
src/brpc/selective_channel.h:
##########
@@ -67,9 +70,10 @@ class SelectiveChannel : public ChannelBase/*non-copyable*/ {
// NOTE: Different from pchan, schan can add channels at any time.
// Returns 0 on success, -1 otherwise.
int AddChannel(ChannelBase* sub_channel, ChannelHandle* handle);
+ int AddChannel(ChannelBase* sub_channel, const std::string& tag, ChannelHandle* handle);
// Remove and destroy the sub_channel associated with `handle'.
- void RemoveAndDestroyChannel(ChannelHandle handle);
+ void RemoveAndDestroyChannel(const ChannelHandle& handle);
Review Comment:
The signature change from passing ChannelHandle by value to passing by const reference is a breaking API change. Existing code that calls RemoveAndDestroyChannel with a SocketId (which was the old ChannelHandle typedef) will fail to compile. Since ChannelHandle is now a struct, consider providing an overload that accepts just a SocketId for backward compatibility, or ensure all users are aware of this breaking change.
##########
src/brpc/selective_channel.h:
##########
@@ -51,7 +51,10 @@ namespace brpc {
// in `done'.
class SelectiveChannel : public ChannelBase/*non-copyable*/ {
public:
- typedef SocketId ChannelHandle;
+ struct ChannelHandle {
+ SocketId id;
+ std::string tag;
Review Comment:
This is a breaking API change. The ChannelHandle type is changed from a simple typedef (SocketId) to a struct containing both id and tag. This breaks backward compatibility for existing code that treats ChannelHandle as a SocketId value. Users who pass ChannelHandle by value or compare it directly with SocketId will experience compilation errors. Consider whether a deprecation period or alternative approach would be more appropriate for this public API change.
```suggestion
std::string tag;
// Backward-compatible constructors and conversion operators so that
// ChannelHandle can still be used where a SocketId was expected.
ChannelHandle()
: id(INVALID_SOCKET_ID) {}
ChannelHandle(SocketId sid)
: id(sid) {}
ChannelHandle(SocketId sid, const std::string& t)
: id(sid), tag(t) {}
// Implicit conversion to SocketId for existing code that treats
// ChannelHandle as a SocketId value.
operator SocketId() const { return id; }
// Assignment from SocketId for source compatibility.
ChannelHandle& operator=(SocketId sid) {
id = sid;
tag.clear();
return *this;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "altman08 (via GitHub)" <gi...@apache.org>.
altman08 commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3722731735
> LGTM
When using the selective channel, I encountered a coredump issue. In the case of a selective channel timeout, the main_cntl rest the lb but does not destroy the call_id. When the sub channel's RPC ends, it can still lock the call_id and call lb's feedback, causing a core dump. I simply added a check for the validity of lb in the feedback function, but I'm not sure if you have better suggestions to resolve this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "yanglimingcn (via GitHub)" <gi...@apache.org>.
yanglimingcn merged PR #3189:
URL: https://github.com/apache/brpc/pull/3189
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "altman08 (via GitHub)" <gi...@apache.org>.
altman08 commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3737274875
> SubDone::Run
If main_cntl times out and SubDone::Run returns directly without calling OnVersionedRPCReturned, it will prevent Sender::Run from being invoked to clear resource. However, if OnVersionedRPCReturned is called, the issue of lb being set to null still persists.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3732140606
> I simply added a check for the validity of lb in the feedback function
I think this will work.
Furthermore, Is it possible that if sub_done finds that main_cntl is Failed with the error code ERPCTIMEDOUT in SubDone::Run, it can skip executing OnVersionedRPCReturned function and return directly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on code in PR #3189:
URL: https://github.com/apache/brpc/pull/3189#discussion_r2668541637
##########
src/brpc/selective_channel.cpp:
##########
@@ -534,16 +533,22 @@ bool SelectiveChannel::initialized() const {
int SelectiveChannel::AddChannel(ChannelBase* sub_channel,
ChannelHandle* handle) {
+ return AddChannel(sub_channel, "", handle);
+}
+
+int SelectiveChannel::AddChannel(ChannelBase* sub_channel,
+ const std::string& tag,
+ ChannelHandle* handle) {
schan::ChannelBalancer* lb =
- static_cast<schan::ChannelBalancer*>(_chan._lb.get());
+ static_cast<schan::ChannelBalancer*>(_chan._lb.get());
Review Comment:
No need to modify this line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "altman08 (via GitHub)" <gi...@apache.org>.
altman08 commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3721743893
> Can you explain in what scenarios does a selective channel need a tag ?
I need to implement my own load balancer plugin, which requires passing parameters via load balancer tags. Similarly, if using built-in load balancer plugins like WRR, I also need to pass parameters via tags.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3722022783
LGTM
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "yanglimingcn (via GitHub)" <gi...@apache.org>.
yanglimingcn commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3722246683
LGTM
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on PR #3189:
URL: https://github.com/apache/brpc/pull/3189#issuecomment-3721724441
Can you explain in what scenarios does a selective channel need a tag ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] surpport tag for selective channel (brpc)
Posted by "altman08 (via GitHub)" <gi...@apache.org>.
altman08 commented on code in PR #3189:
URL: https://github.com/apache/brpc/pull/3189#discussion_r2674640599
##########
src/brpc/selective_channel.cpp:
##########
@@ -534,16 +533,22 @@ bool SelectiveChannel::initialized() const {
int SelectiveChannel::AddChannel(ChannelBase* sub_channel,
ChannelHandle* handle) {
+ return AddChannel(sub_channel, "", handle);
+}
+
+int SelectiveChannel::AddChannel(ChannelBase* sub_channel,
+ const std::string& tag,
+ ChannelHandle* handle) {
schan::ChannelBalancer* lb =
- static_cast<schan::ChannelBalancer*>(_chan._lb.get());
+ static_cast<schan::ChannelBalancer*>(_chan._lb.get());
Review Comment:
> No need to modify this line.
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org