Skip to content

Commit

Permalink
Stub out set_vhost_limits in ctl
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Jan 19, 2016
1 parent 0e5362d commit 7fc5f1a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
37 changes: 34 additions & 3 deletions docs/rabbitmqctl.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,37 @@
</variablelist>
</refsect2>

<refsect2>
<title>Virtual Host Limits</title>
<para>
It is possible to enforce certain limits on virtual hosts.
</para>
<variablelist>
<varlistentry>
<term><cmdsynopsis><command>set_vhost_limits</command> <arg choice="opt">-p <replaceable>vhostpath</replaceable></arg> <arg choice="opt">--max-connections <replaceable>number</replaceable></arg></cmdsynopsis></term>
<listitem>
<para>
Sets virtual host limits
</para>
<variablelist>
<varlistentry>
<term>max-connections</term>
<listitem><para>
How many concurrent client connections are allowed. 0 means "no limit". Default is "no limit".
</para></listitem>
</varlistentry>
</variablelist>
<para role="example-prefix">For example:</para>
<screen role="example">rabbitmqctl set_vhost_limits -p qa_env --max-connections 1024</screen>
<para role="example">
This command limits the max number of concurrent connections in vhost <command>qa_env</command>
to 1024.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>

<refsect2>
<title>Server Status</title>
<para>
Expand Down Expand Up @@ -1994,9 +2025,9 @@
<varlistentry>
<term>fraction</term>
<listitem><para>
Limit relative to the total amount available RAM
as a non-negative floating point number.
Values lower than 1.0 can be dangerous and
Limit relative to the total amount available RAM
as a non-negative floating point number.
Values lower than 1.0 can be dangerous and
should be used carefully.
</para></listitem>
</varlistentry>
Expand Down
3 changes: 3 additions & 0 deletions include/rabbit_cli.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
-define(OFFLINE_OPT, "--offline").
-define(ONLINE_OPT, "--online").

-define(MAX_CONNECTIONS_OPT, "--max-connections").

-define(NODE_DEF(Node), {?NODE_OPT, {option, Node}}).
-define(QUIET_DEF, {?QUIET_OPT, flag}).
Expand All @@ -47,6 +48,8 @@
-define(OFFLINE_DEF, {?OFFLINE_OPT, flag}).
-define(ONLINE_DEF, {?ONLINE_OPT, flag}).

-define(MAX_CONNECTIONS_DEF, {?MAX_CONNECTIONS_OPT, {option, "0"}}).

-define(RPC_TIMEOUT, infinity).

%% Subset of standartized exit codes from sysexits.h, see
Expand Down
8 changes: 8 additions & 0 deletions src/rabbit_control_main.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
{clear_policy, [?VHOST_DEF]},
{list_policies, [?VHOST_DEF]},

{set_vhost_limits, [?VHOST_DEF, ?MAX_CONNECTIONS_DEF]},

{list_queues, [?VHOST_DEF]},
{list_exchanges, [?VHOST_DEF]},
{list_bindings, [?VHOST_DEF]},
Expand Down Expand Up @@ -512,6 +514,12 @@ action(clear_policy, Node, [Key], Opts, Inform) ->
Inform("Clearing policy ~p", [Key]),
rpc_call(Node, rabbit_policy, delete, [VHostArg, list_to_binary(Key)]);

action(set_vhost_limits, _Node, [], Opts, Inform) ->
Msg = "Setting vhost limits for vhost ~p",
VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)),
Inform(Msg, [VHostArg]),
ok;

action(report, Node, _Args, _Opts, Inform) ->
Inform("Reporting server status on ~p~n~n", [erlang:universaltime()]),
[begin ok = action(Action, N, [], [], Inform), io:nl() end ||
Expand Down

0 comments on commit 7fc5f1a

Please sign in to comment.