-
Notifications
You must be signed in to change notification settings - Fork 592
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
c/backend: shard_table to be able to notify subscribers #19623
c/backend: shard_table to be able to notify subscribers #19623
Conversation
/dt |
843b0b6
to
fd67174
Compare
/dt |
test failure due to #14898 |
fd67174
to
c943a09
Compare
raft::group_id g, | ||
std::optional<ss::shard_id> shard)>; | ||
|
||
notification_id_type register_notification(change_cb_t&& cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to take r-value reference here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can name a couple of reasons to use r-value reference here:
- Hinting move semantics to the caller without making them look into the type definition. Might seem useless here, as how do they know the callback signature, but what if they already have the callback value and are making an attempt to reuse it they will probably realise it won't work a bit earlier.
- Optimizing out actual moves https://godbolt.org/z/qbcManb57. They are probably cheap but not zero-cost.
Any reasons to pass by value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the primary reason is that (1) it's already non-copyable so you have to move it--no benefit in semantics and (2) it's not in a hot path, right? so copying 40 bytes during registration is nothing. anyway, nothing wrong with using && but it's nice to default to value semantics where possible. no need to change or anything.
Make shard_table able to notify subscribers. Needed for cross-cluster migrations: as partitions move across shards, shard 0 on each node will re-dispatch partition operations to new shards.
Backports Required
Release Notes