mirror of
https://github.com/rancher/steve.git
synced 2025-09-15 23:08:26 +00:00
Keep track of events for SQL cache watches (#661)
* Keep track of past events * Clarify RV acronym * Fix comment typo * Rename listEvents variables * Improve filter readability * Move defer
This commit is contained in:
@@ -569,6 +569,7 @@ func (s *Store) watch(apiOp *types.APIRequest, schema *types.APISchema, w types.
|
||||
}
|
||||
|
||||
opts := informer.WatchOptions{
|
||||
ResourceVersion: w.Revision,
|
||||
Filter: informer.WatchFilter{
|
||||
ID: w.ID,
|
||||
Namespace: idNamespace,
|
||||
@@ -737,7 +738,7 @@ func (s *Store) Delete(apiOp *types.APIRequest, schema *types.APISchema, id stri
|
||||
// - the total number of resources (returned list might be a subset depending on pagination options in apiOp)
|
||||
// - a continue token, if there are more pages after the returned one
|
||||
// - an error instead of all of the above if anything went wrong
|
||||
func (s *Store) ListByPartitions(apiOp *types.APIRequest, schema *types.APISchema, partitions []partition.Partition) ([]unstructured.Unstructured, int, string, error) {
|
||||
func (s *Store) ListByPartitions(apiOp *types.APIRequest, schema *types.APISchema, partitions []partition.Partition) (*unstructured.UnstructuredList, int, string, error) {
|
||||
opts, err := listprocessor.ParseQuery(apiOp, s.namespaceCache)
|
||||
if err != nil {
|
||||
return nil, 0, "", err
|
||||
@@ -768,7 +769,7 @@ func (s *Store) ListByPartitions(apiOp *types.APIRequest, schema *types.APISchem
|
||||
return nil, 0, "", err
|
||||
}
|
||||
|
||||
return list.Items, total, continueToken, nil
|
||||
return list, total, continueToken, nil
|
||||
}
|
||||
|
||||
// WatchByPartitions returns a channel of events for a list or resource belonging to any of the specified partitions
|
||||
|
@@ -249,7 +249,7 @@ func TestListByPartitions(t *testing.T) {
|
||||
bloi.EXPECT().ListByOptions(req.Context(), &opts, partitions, req.Namespace).Return(listToReturn, len(listToReturn.Items), "", nil)
|
||||
list, total, contToken, err := s.ListByPartitions(req, schema, partitions)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, expectedItems, list)
|
||||
assert.Equal(t, expectedItems, list.Items)
|
||||
assert.Equal(t, len(expectedItems), total)
|
||||
assert.Equal(t, "", contToken)
|
||||
},
|
||||
@@ -466,7 +466,7 @@ func TestListByPartitions(t *testing.T) {
|
||||
bloi.EXPECT().ListByOptions(req.Context(), &opts, partitions, req.Namespace).Return(listToReturn, len(listToReturn.Items), "", nil)
|
||||
list, total, contToken, err := s.ListByPartitions(req, schema, partitions)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, expectedItems, list)
|
||||
assert.Equal(t, expectedItems, list.Items)
|
||||
assert.Equal(t, len(expectedItems), total)
|
||||
assert.Equal(t, "", contToken)
|
||||
},
|
||||
|
Reference in New Issue
Block a user