Skip to content
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_tree: Add an option to accumulate keep-while expirations #301

Closed
wants to merge 1 commit into from

Commits on Oct 7, 2024

  1. khepri_tree: Add an option to accumulate keep-while expirations

    This change adds a type `khepri:delete_options()` similar to
    `khepri:put_options()` which includes a new option
    `return_keep_while_expirations`. Setting this option in a call to
    `khepri_adv:delete_many/3` or `khepri_tx_adv:delete_many/2` will include
    any tree nodes deleted because of expired keep-while conditions in the
    `khepri_adv:many_results()` return value.
    
    In order to accumulate these deletions we need to modify
    `khepri_machine:remove_expired_nodes/2` slightly to pass the fold
    function and accumulator for the current `#walk{..}`.
    
    This option is useful for callers if they need to do something with any
    tree nodes which were deleted by keep-while conditions. For example in
    RabbitMQ we currently delete all bindings which are associated with a
    queue in a transaction. Bindings should always be removed when their
    associated queue is removed so they seem like an ideal case to use a
    keep-while condition. We send notifications and invoke callbacks with
    the set of bindings which were deleted though, so we need to return
    these deleted records. With this change we can avoid performing binding
    deletion in a transaction and instead only delete the queue record while
    providing the new option. This is significantly more efficient because
    of the way the Khepri store is organized in RabbitMQ.
    the-mikedavis committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    0d3b3f5 View commit details
    Browse the repository at this point in the history