summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-04-19 14:07:20 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-04-19 14:07:20 +0100
commit38c936a7ee2a179592a0e991885858e887df8327 (patch)
tree2b180fa3d50f046afc2e455e8291859cf075cfe1 /src
parentb4c15dffdfb76eb8254b78f53836e5b777d3b542 (diff)
downloadrabbitmq-server-git-38c936a7ee2a179592a0e991885858e887df8327.tar.gz
s/app_name/component/g
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_control.erl14
-rw-r--r--src/rabbit_runtime_parameters.erl93
2 files changed, 54 insertions, 53 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index f41d465e3a..9f99f17a0b 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -350,15 +350,15 @@ action(list_permissions, Node, [], Opts, Inform) ->
list_vhost_permissions, [VHost]}),
rabbit_auth_backend_internal:vhost_perms_info_keys());
-action(set_parameter, Node, [AppName, Key, Value], _Opts, Inform) ->
- Inform("Setting runtime parameter ~p for app ~p to ~p",
- [Key, AppName, Value]),
+action(set_parameter, Node, [Component, Key, Value], _Opts, Inform) ->
+ Inform("Setting runtime parameter ~p for component ~p to ~p",
+ [Key, Component, Value]),
rpc_call(Node, rabbit_runtime_parameters, parse_set,
- [list_to_binary(AppName), list_to_binary(Key), Value]);
+ [list_to_binary(Component), list_to_binary(Key), Value]);
-action(clear_parameter, Node, [AppName, Key], _Opts, Inform) ->
- Inform("Clearing runtime parameter ~p for app ~p", [Key, AppName]),
- rpc_call(Node, rabbit_runtime_parameters, clear, [list_to_binary(AppName),
+action(clear_parameter, Node, [Component, Key], _Opts, Inform) ->
+ Inform("Clearing runtime parameter ~p for component ~p", [Key, Component]),
+ rpc_call(Node, rabbit_runtime_parameters, clear, [list_to_binary(Component),
list_to_binary(Key)]);
action(list_parameters, Node, Args = [], _Opts, Inform) ->
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl
index a8fa9d3329..e1c417c410 100644
--- a/src/rabbit_runtime_parameters.erl
+++ b/src/rabbit_runtime_parameters.erl
@@ -48,14 +48,14 @@
%%---------------------------------------------------------------------------
-parse_set(AppName, Key, String) ->
+parse_set(Component, Key, String) ->
case parse(String) of
- {ok, Term} -> set(AppName, Key, Term);
+ {ok, Term} -> set(Component, Key, Term);
{errors, L} -> format_error(L)
end.
-set(AppName, Key, Term) ->
- case set0(AppName, Key, Term) of
+set(Component, Key, Term) ->
+ case set0(Component, Key, Term) of
ok -> ok;
{errors, L} -> format_error(L)
end.
@@ -63,16 +63,16 @@ set(AppName, Key, Term) ->
format_error(L) ->
{error_string, rabbit_misc:format_many([{"Validation failed~n", []} | L])}.
-set0(AppName, Key, Term) ->
- case lookup_app(AppName) of
+set0(Component, Key, Term) ->
+ case lookup_component(Component) of
{ok, Mod} ->
case flatten_errors(validate(Term)) of
ok ->
- case flatten_errors(Mod:validate(AppName, Key, Term)) of
+ case flatten_errors(Mod:validate(Component, Key, Term)) of
ok ->
- case mnesia_update(AppName, Key, Term) of
+ case mnesia_update(Component, Key, Term) of
{old, Term} -> ok;
- _ -> Mod:notify(AppName, Key, Term)
+ _ -> Mod:notify(Component, Key, Term)
end,
ok;
E ->
@@ -85,46 +85,46 @@ set0(AppName, Key, Term) ->
E
end.
-mnesia_update(AppName, Key, Term) ->
+mnesia_update(Component, Key, Term) ->
rabbit_misc:execute_mnesia_transaction(
fun () ->
- Res = case mnesia:read(?TABLE, {AppName, Key}) of
+ Res = case mnesia:read(?TABLE, {Component, Key}) of
[] -> new;
[Params] -> {old, Params#runtime_parameters.value}
end,
- ok = mnesia:write(?TABLE, c(AppName, Key, Term), write),
+ ok = mnesia:write(?TABLE, c(Component, Key, Term), write),
Res
end).
-clear(AppName, Key) ->
- case clear0(AppName, Key) of
+clear(Component, Key) ->
+ case clear0(Component, Key) of
ok -> ok;
{errors, L} -> format_error(L)
end.
-clear0(AppName, Key) ->
- case lookup_app(AppName) of
- {ok, Mod} -> case flatten_errors(Mod:validate_clear(AppName, Key)) of
- ok -> mnesia_clear(AppName, Key),
- Mod:notify_clear(AppName, Key),
+clear0(Component, Key) ->
+ case lookup_component(Component) of
+ {ok, Mod} -> case flatten_errors(Mod:validate_clear(Component, Key)) of
+ ok -> mnesia_clear(Component, Key),
+ Mod:notify_clear(Component, Key),
ok;
E -> E
end;
E -> E
end.
-mnesia_clear(AppName, Key) ->
+mnesia_clear(Component, Key) ->
ok = rabbit_misc:execute_mnesia_transaction(
fun () ->
- ok = mnesia:delete(?TABLE, {AppName, Key}, write)
+ ok = mnesia:delete(?TABLE, {Component, Key}, write)
end).
list() ->
[p(P) || P <- rabbit_misc:dirty_read_all(?TABLE)].
-list(AppName) ->
- case lookup_app(AppName) of
- {ok, _} -> Match = #runtime_parameters{key = {AppName, '_'}, _ = '_'},
+list(Component) ->
+ case lookup_component(Component) of
+ {ok, _} -> Match = #runtime_parameters{key = {Component, '_'}, _ = '_'},
[p(P) || P <- mnesia:dirty_match_object(?TABLE, Match)];
_ -> not_found
end.
@@ -132,56 +132,57 @@ list(AppName) ->
list_formatted() ->
[pset(value, format(pget(value, P)), P) || P <- list()].
-lookup(AppName, Key) ->
- case lookup0(AppName, Key, rabbit_misc:const(not_found)) of
+lookup(Component, Key) ->
+ case lookup0(Component, Key, rabbit_misc:const(not_found)) of
not_found -> not_found;
Params -> p(Params)
end.
-value(AppName, Key) ->
- case lookup0(AppName, Key, rabbit_misc:const(not_found)) of
+value(Component, Key) ->
+ case lookup0(Component, Key, rabbit_misc:const(not_found)) of
not_found -> not_found;
Params -> Params#runtime_parameters.value
end.
-value(AppName, Key, Default) ->
- Params = lookup0(AppName, Key,
- fun () -> lookup_missing(AppName, Key, Default) end),
+value(Component, Key, Default) ->
+ Params = lookup0(Component, Key,
+ fun () -> lookup_missing(Component, Key, Default) end),
Params#runtime_parameters.value.
-lookup0(AppName, Key, DefaultFun) ->
- case mnesia:dirty_read(?TABLE, {AppName, Key}) of
+lookup0(Component, Key, DefaultFun) ->
+ case mnesia:dirty_read(?TABLE, {Component, Key}) of
[] -> DefaultFun();
[R] -> R
end.
-lookup_missing(AppName, Key, Default) ->
+lookup_missing(Component, Key, Default) ->
rabbit_misc:execute_mnesia_transaction(
fun () ->
- case mnesia:read(?TABLE, {AppName, Key}) of
- [] -> Record = c(AppName, Key, Default),
+ case mnesia:read(?TABLE, {Component, Key}) of
+ [] -> Record = c(Component, Key, Default),
mnesia:write(?TABLE, Record, write),
Record;
[R] -> R
end
end).
-c(AppName, Key, Default) -> #runtime_parameters{key = {AppName, Key},
- value = Default}.
+c(Component, Key, Default) -> #runtime_parameters{key = {Component, Key},
+ value = Default}.
-p(#runtime_parameters{key = {AppName, Key}, value = Value}) ->
- [{app_name, AppName},
- {key, Key},
- {value, Value}].
+p(#runtime_parameters{key = {Component, Key}, value = Value}) ->
+ [{component, Component},
+ {key, Key},
+ {value, Value}].
-info_keys() -> [app_name, key, value].
+info_keys() -> [component, key, value].
%%---------------------------------------------------------------------------
-lookup_app(App) ->
+lookup_component(Component) ->
case rabbit_registry:lookup_module(
- runtime_parameter, list_to_atom(binary_to_list(App))) of
- {error, not_found} -> {errors, [{"application ~s not found", [App]}]};
+ runtime_parameter, list_to_atom(binary_to_list(Component))) of
+ {error, not_found} -> {errors,
+ [{"component ~s not found", [Component]}]};
{ok, Module} -> {ok, Module}
end.