-
Notifications
You must be signed in to change notification settings - Fork 10.3k
client/v3: add MemberWatcher helper for polling-based member changes #21184
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi @MkDev11. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/assign @MkDev11 |
This adds a client-side utility for watching membership changes by
polling MemberList() and comparing with the previous state.
This approach follows the maintainer's suggestion to implement member
watching on the client side rather than adding server complexity.
Usage:
watcher := clientv3.NewMemberWatcher(client, clientv3.MemberWatchConfig{
PollInterval: 5 * time.Second,
})
for event := range watcher.Watch(ctx, true) {
fmt.Printf("Event: %v, Member: %s\n", event.Type, event.Member.Name)
}
Event types:
- MemberAdded: new member joined
- MemberRemoved: member was removed
- MemberUpdated: member's peer URLs changed
Fixes: etcd-io#5277
Signed-off-by: MkDev11 <[email protected]>
0adc10f to
0ed5093
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MkDev11 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@ahrtr could you please have a look at the PR and let me know your feedback? thanks. |
Sorry, I should be clearer. The comment #5277 (comment) is just a workaround solution for users reference. I didn't mean to add it into etcd's client SDK. |
What this PR does
This adds a client-side utility for watching membership changes by polling
MemberList()and comparing with the previous state.Fixes: #5277
Why we need it
Users want to watch for membership changes in etcd v3. Following maintainer feedback, this implements the functionality on the client side rather than adding server complexity.
This approach uses the existing
Sync()andMemberList()APIs as suggested by @ahrtr.Changes
Added single file:
client/v3/member_watch.goMemberWatcherstruct with configurable poll intervalMemberEventandMemberEventTypetypesWatch()method that returns a channel of membership eventsUsage
Event types
MemberAddedMemberRemovedMemberUpdatedTest Results
Testing checklist
go build ./client/v3/...)