-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add iteration support to etcd #52199
Conversation
fbff95f
to
2d169d0
Compare
I attempted to determine the performance impact of this change by running a modified version of BenchmarkGetNodes to run against etcd and for the sake of time a single node count.
|
2d169d0
to
54cdcff
Compare
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.
If we want to follow https://pkg.go.dev/iter#hdr-Naming_Conventions we should call the method Range
or something like that, shouldn't we?
6c241ca
to
d8a4268
Compare
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.
LGTM once error handling is improved.
b16e09f
to
0f9445a
Compare
b9dea9e
to
b4dd722
Compare
Introduces a new `Items(context.Context, backend.IterateParams) iter.Seq2[backend.Item, error]` to the etcd backend. The core logic for this function was moved from GetRange, and GetRange now defers to calling Items and collecting a slice of items. The motivation for this change is to attempt to reduce the complexity of pagination for consumers of GetRange. While backend.IterateRange and backend.StreamRange do already exists to serve the same purpose, they too have suffered from pagination bugs in the past. Additionally, this aims to unify iteration to using the iter package instead of the various homegrown iteration mechanisms that exist throughout the code base. There is also one distinct difference to the iteration api: it allows retrieving items within the specified range in ascending or descending key order. While there may not be many use cases for this today, exposing this in the api from it's inception is easier than adding functional options, or ItemsAscending/ItemsDescending later.
b4dd722
to
e97a438
Compare
Introduces a new
Items(context.Context, backend.IterateParams) iter.Seq2[backend.Item, error]
to the etcd backend. The core logic for this function was moved from GetRange, and GetRange now defers to calling Iterate and collecting a slice of items.The motivation for this change is to attempt to reduce the complexity of pagination for consumers of GetRange. While
backend.IterateRange
andbackend.StreamRange
do already exists to serve the same purpose, they too have suffered from pagination bugs in the past. Additionally, this aims to unify iteration to using the iter package instead of the various homegrown iteration mechanisms that exist throughout the code base.There is also one distinct difference to the iteration api: it allows retrieving items within the specified range in ascending or descending key order. While there may not be many use cases for this today, exposing this in the api from it's inception is easier than adding functional options, or IterateAscending/IterateDescending later.