summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_cli
diff options
context:
space:
mode:
authordcorbacho <dparracorbacho@piotal.io>2020-03-16 17:30:14 +0000
committerkjnilsson <knilsson@pivotal.io>2020-09-30 16:34:50 +0100
commitfb8610ff44d594f821111ddb92f913de544fc096 (patch)
tree9f0a16885e8992ec3a26f87e86c0d15a00e904a2 /deps/rabbitmq_cli
parentb2698901d33bcc6b747cefbee20f9d1d6ab63e8f (diff)
downloadrabbitmq-server-git-fb8610ff44d594f821111ddb92f913de544fc096.tar.gz
Add/delete stream replica commands
New ctl utility for stream queues [#171207068]
Diffstat (limited to 'deps/rabbitmq_cli')
-rw-r--r--deps/rabbitmq_cli/Makefile4
-rw-r--r--deps/rabbitmq_cli/README.md4
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/core/doc_guide.ex3
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/add_replica_command.ex72
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/delete_replica_command.ex69
-rw-r--r--deps/rabbitmq_cli/mix.exs1
6 files changed, 149 insertions, 4 deletions
diff --git a/deps/rabbitmq_cli/Makefile b/deps/rabbitmq_cli/Makefile
index 963a8a1f81..90938066f4 100644
--- a/deps/rabbitmq_cli/Makefile
+++ b/deps/rabbitmq_cli/Makefile
@@ -43,6 +43,7 @@ ACTUAL_ESCRIPTS = escript/rabbitmqctl
LINKED_ESCRIPTS = escript/rabbitmq-plugins \
escript/rabbitmq-diagnostics \
escript/rabbitmq-queues \
+ escript/rabbitmq-streams \
escript/rabbitmq-upgrade
ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)
@@ -51,8 +52,9 @@ ESCRIPTS = $(ACTUAL_ESCRIPTS) $(LINKED_ESCRIPTS)
rabbitmq-plugins = escript/rabbitmqctl
rabbitmq-diagnostics = escript/rabbitmqctl
rabbitmq-queues = escript/rabbitmqctl
+rabbitmq-streams = escript/rabbitmqctl
rabbitmq-upgrade = escript/rabbitmqctl
-escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-upgrade: escript/rabbitmqctl
+escript/rabbitmq-plugins escript/rabbitmq-diagnostics escript/rabbitmq-queues escript/rabbitmq-streams escript/rabbitmq-upgrade: escript/rabbitmqctl
# We use hardlinks or symlinks in the `escript` directory and
# install's PREFIX when a single escript can have several names (eg.
diff --git a/deps/rabbitmq_cli/README.md b/deps/rabbitmq_cli/README.md
index a9a29173a1..1d1c1664d0 100644
--- a/deps/rabbitmq_cli/README.md
+++ b/deps/rabbitmq_cli/README.md
@@ -42,7 +42,7 @@ Dependencies are being resolved by `erlang.mk`
### Building Standalone Executables
This repo produces a `rabbitmqctl` executable which can be used as different tools
-(`rabbitmq-plugins`, `rabbitmq-diagnostics`, `rabbitmq-queues`, `rabbitmq-upgrade`) by copying or symlinking it with different names.
+(`rabbitmq-plugins`, `rabbitmq-diagnostics`, `rabbitmq-queues`, `rabbitmq-streams`, `rabbitmq-upgrade`) by copying or symlinking it with different names.
Depending on the name, a different set of commands will be loaded and available, including
for `--help`.
@@ -105,7 +105,7 @@ There are also a number of optional callbacks:
* `usage_additional`: extra values appended to the `usage` output
to provide additional command-specific documentation.
* `scopes`: what scopes this command appears in. Scopes associate
- tools (e.g. `rabbitmqctl`, `rabbitmq-diagnostics`, `rabbitmq-queues`) with commands.
+ tools (e.g. `rabbitmqctl`, `rabbitmq-diagnostics`, `rabbitmq-queues`, `rabbitmq-streams`) with commands.
* `distribution`: control erlang distribution.
Can be `:cli` (default), `:none` or `{:fun, fun}`
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/doc_guide.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/doc_guide.ex
index f0627c526e..c75dcb0d7c 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/doc_guide.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/doc_guide.ex
@@ -57,7 +57,8 @@ defmodule RabbitMQ.CLI.Core.DocGuide do
Macros.defguide("publishers")
Macros.defguide("plugins")
Macros.defguide("queues")
- Macros.defguide("quorum_queues")
+ Macros.defguide("quorum_queues", domain: "next.rabbitmq.com")
+ Macros.defguide("stream_queues", domain: "next.rabbitmq.com")
Macros.defguide("runtime_tuning", path_segment: "runtime")
Macros.defguide("tls", path_segment: "ssl")
Macros.defguide("troubleshooting")
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/add_replica_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/add_replica_command.ex
new file mode 100644
index 0000000000..0444c2e7ef
--- /dev/null
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/add_replica_command.ex
@@ -0,0 +1,72 @@
+## The contents of this file are subject to the Mozilla Public License
+## Version 1.1 (the "License"); you may not use this file except in
+## compliance with the License. You may obtain a copy of the License
+## at https://www.mozilla.org/MPL/
+##
+## Software distributed under the License is distributed on an "AS IS"
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+## the License for the specific language governing rights and
+## limitations under the License.
+##
+## The Original Code is RabbitMQ.
+##
+## Copyright (c) 2012-2020 VMware, Inc. or its affiliates. All rights reserved.
+
+defmodule RabbitMQ.CLI.Streams.Commands.AddReplicaCommand do
+ alias RabbitMQ.CLI.Core.DocGuide
+ import Rabbitmq.Atom.Coerce
+
+ @behaviour RabbitMQ.CLI.CommandBehaviour
+
+ def merge_defaults(args, opts) do
+ {args, Map.merge(%{vhost: "/"}, opts)}
+ end
+
+ use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
+ use RabbitMQ.CLI.Core.AcceptsTwoPositionalArguments
+ use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
+
+ def run([name, node] = _args, %{vhost: vhost, node: node_name}) do
+ case :rabbit_misc.rpc_call(node_name, :rabbit_stream_queue, :add_replica, [
+ vhost,
+ name,
+ to_atom(node)
+ ]) do
+ {:error, :classic_queue_not_supported} ->
+ {:error, "Cannot add replicas to a classic queue"}
+
+ {:error, :quorum_queue_not_supported} ->
+ {:error, "Cannot add replicas to a quorum queue"}
+
+ other ->
+ other
+ end
+ end
+
+ use RabbitMQ.CLI.DefaultOutput
+
+ def usage, do: "add_replica [--vhost <vhost>] <queue> <node>"
+
+ def usage_additional do
+ [
+ ["<queue>", "stream queue name"],
+ ["<node>", "node to add a new replica on"]
+ ]
+ end
+
+ def usage_doc_guides() do
+ [
+ DocGuide.stream_queues()
+ ]
+ end
+
+ def help_section, do: :replication
+
+ def description, do: "Adds a stream queue replica on the given node."
+
+ def banner([name, node], _) do
+ [
+ "Adding a replica for queue #{name} on node #{node}..."
+ ]
+ end
+end
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/delete_replica_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/delete_replica_command.ex
new file mode 100644
index 0000000000..a149f46cae
--- /dev/null
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/delete_replica_command.ex
@@ -0,0 +1,69 @@
+## The contents of this file are subject to the Mozilla Public License
+## Version 1.1 (the "License"); you may not use this file except in
+## compliance with the License. You may obtain a copy of the License
+## at https://www.mozilla.org/MPL/
+##
+## Software distributed under the License is distributed on an "AS IS"
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+## the License for the specific language governing rights and
+## limitations under the License.
+##
+## The Original Code is RabbitMQ.
+##
+## Copyright (c) 2012-2020 VMware, Inc. or its affiliates. All rights reserved.
+
+defmodule RabbitMQ.CLI.Streams.Commands.DeleteReplicaCommand do
+ alias RabbitMQ.CLI.Core.DocGuide
+ import Rabbitmq.Atom.Coerce
+
+ @behaviour RabbitMQ.CLI.CommandBehaviour
+
+ def merge_defaults(args, opts) do
+ {args, Map.merge(%{vhost: "/"}, opts)}
+ end
+
+ use RabbitMQ.CLI.Core.AcceptsTwoPositionalArguments
+ use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
+
+ def run([name, node] = _args, %{vhost: vhost, node: node_name}) do
+ case :rabbit_misc.rpc_call(node_name, :rabbit_stream_queue, :delete_replica, [
+ vhost,
+ name,
+ to_atom(node)
+ ]) do
+ {:error, :classic_queue_not_supported} ->
+ {:error, "Cannot delete replicas on a classic queue"}
+
+ {:error, :quorum_queue_not_supported} ->
+ {:error, "Cannot delete replicas on a quorum queue"}
+
+ other ->
+ other
+ end
+ end
+
+ use RabbitMQ.CLI.DefaultOutput
+
+ def usage, do: "delete_replica [--vhost <vhost>] <queue> <node>"
+
+ def usage_additional do
+ [
+ ["<queue>", "stream queue name"],
+ ["<node>", "node to remove a new replica on"]
+ ]
+ end
+
+ def usage_doc_guides() do
+ [
+ DocGuide.stream_queues()
+ ]
+ end
+
+ def help_section, do: :replication
+
+ def description, do: "Removes a stream queue replica on the given node."
+
+ def banner([name, node], _) do
+ "Removing a replica of queue #{name} on node #{node}..."
+ end
+end
diff --git a/deps/rabbitmq_cli/mix.exs b/deps/rabbitmq_cli/mix.exs
index 24bb5515a5..ecbbbce9a3 100644
--- a/deps/rabbitmq_cli/mix.exs
+++ b/deps/rabbitmq_cli/mix.exs
@@ -31,6 +31,7 @@ defmodule RabbitMQCtl.MixfileBase do
rabbitmqctl: :ctl,
'rabbitmq-diagnostics': :diagnostics,
'rabbitmq-queues': :queues,
+ 'rabbitmq-streams': :streams,
'rabbitmq-upgrade': :upgrade]]
]
|> add_modules(Mix.env)