rabbitmq-server
rabbitmq-server copied to clipboard
Unify Khepri paths API
Why
Currently, rabbit_db_* modules use and export the following kind of functions to return the path to the resources they manage:
khepri_db_thing:khepri_things_path(),
khepri_db_thing:khepri_thing_path(Identifier).
Internally, khepri_db_thing:khepri_thing_path(Identifier) appends Identifier to the list returned by khepri_db_thing:khepri_things_path(). This works for the organization of the records we have today in Khepri:
|-- thing
| |-- <<"identifier1">>
| | <<"identifier2">>
`-- other_thing
`-- <<"other_identifier1">>
However, with the upcoming organization that leverages the tree in Khepri, identifiers may be in the middle of the path instead of a leaf component. We may also put other_thing under thing in the tree.
That's why, we can't really expose a parent directory for thing and other_thing. Therefore, khepri_db_thing:khepri_things_path/0 needs to go away. Only khepri_db_thing:khepri_thing_path/1 should be exported and used.
In addition to that, there are several places where paths are hard-coded (i.e. their definition is duplicated).
How
The patch does exactly that. Uses of khepri_db_thing:khepri_things_path() are generally replaced by rabbit_db_thing:khepri_thing_path(?KHEPRI_WILDCARD_STAR).
Places where the path definitions were duplicated are fixed too by calling the path building functions.
In the future, for a resource that depends on another one, the corresponding module will call the rabbit_db_thing:khepri_thing_path/1 for that other resource and build its path on top of that.