Represent rabbit_binding:deletions()
with a map instead of dict
#12416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a mainly cosmetic refactor that makes the types of
rabbit_binding:deletions()
clearer and easier to work with.The
dict:dict()
typing ofrabbit_binding
appears to be a historical artifact.dict
has been superseded bymaps
. Switching to a map makes deletions easier to inspect manually and faster. Though if deletions grow so large that the map representation is important, manipulation of the deletions is unlikely to be expensive compared to any other operations that produced them, so performance is probably irrelevant.This commit refactors the bottom section of the
rabbit_binding
module to switch to a map, switch thedeletions()
type to an opaque, eliminating a TODO created when using Erlang/OTP 17.1, and the deletion value to a record. We eliminate some historical artifacts and "cruft":{X, deleted | not_deleted, Bindings, none}
no longer being handled.process_deletions/2
was responsible for creating this shape. Instead we now use a record to clearly define the fields.{error, not_found}
are unnecessary after minor refactors of the callers. Removing them makes the type specs cleaner.rabbit_binding:process_deletions/1
has no need to update or change the deletions. This function usesmaps:foreach/2
instead and returnsok
instead of mapped deletions.undefined
from the typespec of deletions. This value is no longer possible with a refactor tomaybe_auto_delete_exchange_in_*
functions for Mnesia and Khepri. The value was nonsensical since you cannot delete bindings for an exchange that does not exist.