feat: Add filter function to reflector::Store#1681
Conversation
Signed-off-by: JPaja <jovan.pavlovic99@gmail.com>
7a8d546 to
031bd3e
Compare
|
Hey there, thanks for this. I think the rational to avoid cloning here makes sense, but it brings up a point we have talked about before; that maybe we should expose an iterator See e.g. #1634 (comment) WDYT? Is an Iterator return type something that would be suitable here? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1681 +/- ##
=======================================
+ Coverage 75.9% 76.0% +0.1%
=======================================
Files 84 84
Lines 7611 7640 +29
=======================================
+ Hits 5771 5800 +29
Misses 1840 1840
|
|
hi @clux, Yeah any solution that does not require cloning everything would work, Regarding iterator solution I'm just worried that RwLock read reference could cause problems in terms of locking out potential writes, because users are responsible of sanely dropping it. Maybe implementing Read/AsyncRead on Cache would solve issue here, allowing AsyncReadExt to handle all possible functions |
Motivation
To get list of items that match predicate from store requires using 'state' function first.
This clones all elements instead of just filtered ones.
Solution
Add function called 'filter' in store that first filters elements and than clones.