-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add iteration support to etcd #52199
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
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
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Both GetRange and DeleteRange were refactored to call Items instead of getAllRecords to unify logic and vet the implementation of Items. The custom pagination logic to retrieve items was also removed in favor of the built in query paginator from the aws sdk. In addition to simplifying logic this also removed some extraneous sorting.
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Both GetRange and DeleteRange were refactored to call Items instead of getAllRecords to unify logic and vet the implementation of Items. The custom pagination logic to retrieve items was also removed in favor of the built in query paginator from the aws sdk. In addition to simplifying logic this also removed some extraneous sorting.
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the memory backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the sqlite backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the postgres backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the firestore backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range. The iteration logic is slightly more complex here to ensure that documents in the collection are produced in the correct order no matter how the key was stored in the collection. Over the years the key has been stored in three different formats, and no single query will pull the items from all keys. There was a background migration task introduced in v17 to convert all keys to a single format. The iteration logic can be simplified once said migration is removed and all keys can be assumed to be of a single type.
This builds on top of #52199 by updating the sqlite backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the postgres backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the memory backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the postgres backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the sqlite backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Both GetRange and DeleteRange were refactored to call Items instead of getAllRecords to unify logic and vet the implementation of Items. The custom pagination logic to retrieve items was also removed in favor of the built in query paginator from the aws sdk. In addition to simplifying logic this also removed some extraneous sorting.
This builds on top of #52199 by updating the memory backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the memory backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range.
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Both GetRange and DeleteRange were refactored to call Items instead of getAllRecords to unify logic and vet the implementation of Items. The custom pagination logic to retrieve items was also replaced with an iterator that works in a similar fashio to the query paginator from the aws sdk. In addition to simplifying logic this also removed some extraneous sorting.
This builds on top of #52199 by updating the dynamo backend to implement backend.BackendWithItems. Both GetRange and DeleteRange were refactored to call Items instead of getAllRecords to unify logic and vet the implementation of Items. The custom pagination logic to retrieve items was also replaced with an iterator that works in a similar fashio to the query paginator from the aws sdk. In addition to simplifying logic this also removed some extraneous sorting.
This builds on top of #52199 by updating the firestore backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range. The iteration logic is slightly more complex here to ensure that documents in the collection are produced in the correct order no matter how the key was stored in the collection. Over the years the key has been stored in three different formats, and no single query will pull the items from all keys. There was a background migration task introduced in v17 to convert all keys to a single format. The iteration logic can be simplified once said migration is removed and all keys can be assumed to be of a single type.
This builds on top of #52199 by updating the firestore backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range. The iteration logic is slightly more complex here to ensure that documents in the collection are produced in the correct order no matter how the key was stored in the collection. Over the years the key has been stored in three different formats, and no single query will pull the items from all keys. There was a background migration task introduced in v17 to convert all keys to a single format. The iteration logic can be simplified once said migration is removed and all keys can be assumed to be of a single type.
This builds on top of #52199 by updating the firestore backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range. The iteration logic is slightly more complex here to ensure that documents in the collection are produced in the correct order no matter how the key was stored in the collection. Over the years the key has been stored in three different formats, and no single query will pull the items from all keys. There was a background migration task introduced in v17 to convert all keys to a single format. The iteration logic can be simplified once said migration is removed and all keys can be assumed to be of a single type.
This builds on top of #52199 by updating the firestore backend to implement backend.BackendWithItems. Only GetRange, and not DeletRange, was refactored to use Items to retrieve a range. The iteration logic is slightly more complex here to ensure that documents in the collection are produced in the correct order no matter how the key was stored in the collection. Over the years the key has been stored in three different formats, and no single query will pull the items from all keys. There was a background migration task introduced in v17 to convert all keys to a single format. The iteration logic can be simplified once said migration is removed and all keys can be assumed to be of a single type.
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.