Skip to content

Commit c9956b0

Browse files
Merge pull request #11614 from rabbitmq/md/remove-dead-rabbit_runtime_parameters-functions
2 parents a4673d4 + 427876b commit c9956b0

File tree

2 files changed

+2
-74
lines changed

2 files changed

+2
-74
lines changed

deps/rabbit/src/rabbit_db_rtparams.erl

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
-export([set/2, set/4,
1414
get/1,
15-
get_or_set/2,
1615
get_all/0, get_all/2,
1716
delete/1, delete/3,
1817
delete_vhost/1]).
@@ -157,61 +156,6 @@ get_in_khepri(Key) ->
157156
[Record] -> Record
158157
end.
159158

160-
%% -------------------------------------------------------------------
161-
%% get_or_set().
162-
%% -------------------------------------------------------------------
163-
164-
-spec get_or_set(Key, Default) -> Ret when
165-
Key :: atom() | {vhost:name(), binary(), binary()},
166-
Default :: any(),
167-
Ret :: #runtime_parameters{}.
168-
%% @doc Returns a runtime parameter or sets its value if it does not exist.
169-
%%
170-
%% @private
171-
172-
get_or_set({VHostName, Comp, Name} = Key, Default)
173-
when is_binary(VHostName) andalso
174-
is_binary(Comp) andalso
175-
(is_binary(Name) orelse is_atom(Name)) ->
176-
rabbit_khepri:handle_fallback(
177-
#{mnesia => fun() -> get_or_set_in_mnesia(Key, Default) end,
178-
khepri => fun() -> get_or_set_in_khepri(Key, Default) end});
179-
get_or_set(Key, Default) ->
180-
rabbit_khepri:handle_fallback(
181-
#{mnesia => fun() -> get_or_set_in_mnesia(Key, Default) end,
182-
khepri => fun() -> get_or_set_in_khepri(Key, Default) end
183-
}).
184-
185-
get_or_set_in_mnesia(Key, Default) ->
186-
rabbit_mnesia:execute_mnesia_transaction(
187-
fun() -> get_or_set_in_mnesia_tx(Key, Default) end).
188-
189-
get_or_set_in_mnesia_tx(Key, Default) ->
190-
case mnesia:read(?MNESIA_TABLE, Key, read) of
191-
[Record] ->
192-
Record;
193-
[] ->
194-
Record = #runtime_parameters{key = Key,
195-
value = Default},
196-
mnesia:write(?MNESIA_TABLE, Record, write),
197-
Record
198-
end.
199-
200-
get_or_set_in_khepri(Key, Default) ->
201-
Path = khepri_rp_path(Key),
202-
rabbit_khepri:transaction(
203-
fun () ->
204-
case khepri_tx:get(Path) of
205-
{ok, undefined} ->
206-
Record = #runtime_parameters{key = Key,
207-
value = Default},
208-
ok = khepri_tx:put(Path, Record),
209-
Record;
210-
{ok, R} ->
211-
R
212-
end
213-
end).
214-
215159
%% -------------------------------------------------------------------
216160
%% get_all().
217161
%% -------------------------------------------------------------------

deps/rabbit/src/rabbit_runtime_parameters.erl

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545
-export([parse_set/5, set/5, set_any/5, clear/4, clear_any/4, list/0, list/1,
4646
list_component/1, list/2, list_formatted/1, list_formatted/3,
47-
lookup/3, value/3, value/4, info_keys/0, clear_vhost/2,
47+
lookup/3, value/3, info_keys/0, clear_vhost/2,
4848
clear_component/2]).
4949

50-
-export([parse_set_global/3, set_global/3, value_global/1, value_global/2,
50+
-export([parse_set_global/3, set_global/3, value_global/1,
5151
list_global/0, list_global_formatted/0, list_global_formatted/2,
5252
lookup_global/1, global_info_keys/0, clear_global/2]).
5353

@@ -347,39 +347,23 @@ lookup_global(Name) ->
347347

348348
value(VHost, Comp, Name) -> value0({VHost, Comp, Name}).
349349

350-
-spec value(rabbit_types:vhost(), binary(), binary(), term()) -> term().
351-
352-
value(VHost, Comp, Name, Def) -> value0({VHost, Comp, Name}, Def).
353-
354350
-spec value_global(atom()) -> term() | 'not_found'.
355351

356352
value_global(Key) ->
357353
value0(Key).
358354

359-
-spec value_global(atom(), term()) -> term().
360-
361-
value_global(Key, Default) ->
362-
value0(Key, Default).
363-
364355
value0(Key) ->
365356
case lookup0(Key, rabbit_misc:const(not_found)) of
366357
not_found -> not_found;
367358
Params -> Params#runtime_parameters.value
368359
end.
369360

370-
value0(Key, Default) ->
371-
Params = lookup0(Key, fun () -> lookup_missing(Key, Default) end),
372-
Params#runtime_parameters.value.
373-
374361
lookup0(Key, DefaultFun) ->
375362
case rabbit_db_rtparams:get(Key) of
376363
undefined -> DefaultFun();
377364
Record -> Record
378365
end.
379366

380-
lookup_missing(Key, Default) ->
381-
rabbit_db_rtparams:get_or_set(Key, Default).
382-
383367
p(#runtime_parameters{key = {VHost, Component, Name}, value = Value}) ->
384368
[{vhost, VHost},
385369
{component, Component},

0 commit comments

Comments
 (0)