-
Notifications
You must be signed in to change notification settings - Fork 20
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
khepri_adv: Add delete_reason
prop, accumulate keep-while expirations
#305
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #305 +/- ##
=======================================
Coverage 89.75% 89.75%
=======================================
Files 22 22
Lines 3230 3241 +11
=======================================
+ Hits 2899 2909 +10
- Misses 331 332 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
95b0ef5
to
c62b421
Compare
This change adds a new `delete_reason` key to the `node_props()` map which is either `direct` or `keep_while`. This commit changes `khepri_tree` to add the `direct` delete reason for tree nodes which were deleted because they were the target of a delete command. The `keep_while` reason will be added in the child commit. The motivation to include a delete reason is that in the child commit we will include tree nodes deleted because their keep-while conditions became unsatisfied. `delete_reason` enables the caller to distinguish between tree nodes deleted "directly" (the target of the delete command) and the others which were expired. It also enables callers of put operations to distinguish between puts (tree node creations and updates) and deletions, since a put operation could also trigger a keep-while expiration.
With this change any tree nodes removed from the tree because their keep-while condition became unsatisfied are accumulated in the return value of the put or delete operation which caused their deletion. These expired tree nodes have props maps in the return map with the `delete_reason` key set to `keep_while`. This enables callers of delete operations to distinguish between deletes which were the target of the delete command (`direct`) and expired nodes (`keep_while`). This also enables callers of put operations to distinguish between creates or updates and deletions. This change only affects functions which return the `khepri_adv:node_props_map()` - functions from the `khepri_adv` and `khepri_adv_tx` modules. Previously the node props map did not include the tree nodes removed because of expired keep-while conditions.
c62b421
to
46b6952
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.
Thank you!
This change adds a
delete_reason
prop to the props map for nodes deleted with a function from the adv APIskhepri_adv
andkhepri_adv_tx
. Tree nodes which are the target of deletion commands gain adelete_reason
property set todirect
. This change also includes any tree nodes which were deleted because of an expired keep-while condition in the node props map. These expired nodes have adelete_reason
property set tokeep_while
instead. Thedelete_reason
property lets callers filter on whether a change was a deletion and distinguish nodes deleted directly or indirectly.