rabbit_db_queue: Use other path functions to extract the name of a queue

[Why]

The function was previously hard-coding the path. Therefore, it was
defined in multiple places. With the upcoming reorganization of the
data, it's best to not do that.
This commit is contained in:
Jean-Sébastien Pédron 2024-07-24 17:55:59 +02:00
parent f745a57ccc
commit b934dc597c
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 11 additions and 1 deletions

View File

@ -1371,5 +1371,15 @@ khepri_queue_path(VHost, Name)
?IS_KHEPRI_PATH_CONDITION(Name) ->
[?MODULE, queues, VHost, Name].
khepri_queue_path_to_name([?MODULE, queues, VHost, Name]) ->
khepri_queue_path_to_name(Path) ->
Pattern = khepri_queue_path('$VHost', '$Name'),
khepri_queue_path_to_name(Pattern, Path, #{}).
khepri_queue_path_to_name([Var | Pattern], [Value | Path], Result)
when Var =:= '$VHost' orelse Var =:= '$Name' ->
Result1 = Result#{Var => Value},
khepri_queue_path_to_name(Pattern, Path, Result1);
khepri_queue_path_to_name([Comp | Pattern], [Comp | Path], Result) ->
khepri_queue_path_to_name(Pattern, Path, Result);
khepri_queue_path_to_name([], _, #{'$VHost' := VHost, '$Name' := Name}) ->
rabbit_misc:r(VHost, queue, Name).