Skip to content

Commit b2b716c

Browse files
authored
Merge pull request #13358 from rabbitmq/deprecate-set-stream-retention-policy-command
Deprecate set_stream_retention_policy command
2 parents afe94a8 + 8465fc5 commit b2b716c

File tree

4 files changed

+18
-89
lines changed

4 files changed

+18
-89
lines changed

deps/rabbit/docs/rabbitmq-streams.8

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
44
.\" file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
.\"
6-
.\" Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
6+
.\" Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
77
.\"
8-
.Dd June 22, 2023
8+
.Dd February 18, 2025
99
.Dt RABBITMQ-STREAMS 8
1010
.Os "RabbitMQ Server"
1111
.Sh NAME
@@ -129,18 +129,6 @@ Example:
129129
.Dl rabbitmq-streams restart_stream --vhost Qo a-vhost Qc Qo a-stream Qc --preferred-leader-node Qo node
130130
.\" ------------------------------------
131131
.El
132-
.Ss Policies
133-
.Bl -tag -width Ds
134-
.\" ------------------------------------
135-
.It Cm set_stream_retention_policy Ar stream Ar policy Fl -vhost Ar virtual-host
136-
.Pp
137-
Set the retention policy of a stream.
138-
.Pp
139-
Example:
140-
.Sp
141-
.Dl rabbitmq-streams set_stream_retention_policy --vhost Qo a-vhost Qc Qo a-stream Qc Qo a-policy Qc
142-
.\" ------------------------------------
143-
.El
144132
.Ss Stream plugin
145133
.Bl -tag -width Ds
146134
.\" ------------------------------------------------------------------

deps/rabbit/src/rabbit_stream_queue.erl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
-export([list_with_minimum_quorum/0]).
4444

45-
-export([set_retention_policy/3]).
4645
-export([restart_stream/3,
4746
add_replica/3,
4847
delete_replica/3,
@@ -999,24 +998,6 @@ update_leader_pid(Pid, #stream_client{} = State) ->
999998
state_info(_) ->
1000999
#{}.
10011000

1002-
set_retention_policy(Name, VHost, Policy) ->
1003-
case rabbit_amqqueue:check_max_age(Policy) of
1004-
{error, _} = E ->
1005-
E;
1006-
MaxAge ->
1007-
QName = queue_resource(VHost, Name),
1008-
Fun = fun(Q) ->
1009-
Conf = amqqueue:get_type_state(Q),
1010-
amqqueue:set_type_state(Q, Conf#{max_age => MaxAge})
1011-
end,
1012-
case rabbit_amqqueue:update(QName, Fun) of
1013-
not_found ->
1014-
{error, not_found};
1015-
_ ->
1016-
ok
1017-
end
1018-
end.
1019-
10201001
-spec restart_stream(VHost :: binary(), Queue :: binary(),
10211002
#{preferred_leader_node => node()}) ->
10221003
{ok, node()} |

deps/rabbitmq_cli/lib/rabbitmq/cli/streams/commands/set_stream_retention_policy_command.ex

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## License, v. 2.0. If a copy of the MPL was not distributed with this
33
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
44
##
5-
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
5+
## Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66

77
defmodule RabbitMQ.CLI.Streams.Commands.SetStreamRetentionPolicyCommand do
88
alias RabbitMQ.CLI.Core.DocGuide
@@ -14,29 +14,18 @@ defmodule RabbitMQ.CLI.Streams.Commands.SetStreamRetentionPolicyCommand do
1414
use RabbitMQ.CLI.Core.AcceptsTwoPositionalArguments
1515
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
1616

17-
def run([name, retention_policy], %{node: node_name, vhost: vhost}) do
18-
:rabbit_misc.rpc_call(node_name, :rabbit_stream_queue, :set_retention_policy, [
19-
name,
20-
vhost,
21-
retention_policy
22-
])
17+
def run(_, _) do
18+
:ok
2319
end
2420

2521
use RabbitMQ.CLI.DefaultOutput
2622

27-
def banner([name, retention_policy], _) do
28-
"Setting retention policy of stream queue #{name} to #{retention_policy} ..."
23+
def banner(_, _) do
24+
"DEPRECATED. This command is a no-op. Use a policy to set data retention."
2925
end
3026

3127
def usage, do: "set_stream_retention_policy [--vhost <vhost>] <name> <policy>"
3228

33-
def usage_additional() do
34-
[
35-
["<name>", "stream queue name"],
36-
["<policy>", "retention policy"]
37-
]
38-
end
39-
4029
def usage_doc_guides() do
4130
[
4231
DocGuide.streams()
@@ -45,5 +34,5 @@ defmodule RabbitMQ.CLI.Streams.Commands.SetStreamRetentionPolicyCommand do
4534

4635
def help_section(), do: :policies
4736

48-
def description(), do: "Sets the retention policy of a stream queue"
37+
def description(), do: "DEPRECATED. This command is a no-op. Use a policy to set data retention."
4938
end

deps/rabbitmq_cli/test/streams/set_stream_retention_policy_command_test.exs

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## License, v. 2.0. If a copy of the MPL was not distributed with this
33
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
44
##
5-
## Copyright (c) 2007-2023 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
5+
## Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66
##
77

88
defmodule RabbitMQ.CLI.Streams.Commands.SetStreamRetentionPolicyCommandTest do
@@ -17,52 +17,23 @@ defmodule RabbitMQ.CLI.Streams.Commands.SetStreamRetentionPolicyCommandTest do
1717
:ok
1818
end
1919

20-
setup context do
20+
setup do
2121
{:ok,
2222
opts: %{
23-
node: get_rabbit_hostname(),
24-
timeout: context[:test_timeout] || 30000
23+
node: get_rabbit_hostname()
2524
}}
2625
end
2726

28-
test "validate: when no arguments are provided, returns a failure" do
29-
assert @command.validate([], %{}) == {:validation_failure, :not_enough_args}
30-
end
31-
32-
test "validate: when one argument is provided, returns a failure" do
33-
assert @command.validate(["stream-queue-a"], %{}) == {:validation_failure, :not_enough_args}
34-
end
35-
36-
test "validate: when three or more arguments are provided, returns a failure" do
37-
assert @command.validate(["stream-queue-a", "1D", "one-extra-arg"], %{}) ==
38-
{:validation_failure, :too_many_args}
39-
40-
assert @command.validate(["stream-queue-a", "1D", "extra-arg", "another-extra-arg"], %{}) ==
41-
{:validation_failure, :too_many_args}
42-
end
43-
44-
test "validate: treats two positional arguments and default switches as a success" do
45-
assert @command.validate(["stream-queue-a", "2Y"], %{}) == :ok
46-
end
47-
48-
@tag test_timeout: 3000
49-
test "run: targeting an unreachable node throws a badrpc" do
27+
test "run: no op", context do
5028
assert match?(
51-
{:badrpc, _},
52-
@command.run(
53-
["stream-queue-a", "1Y"],
54-
%{node: :jake@thedog, vhost: "/", timeout: 200}
55-
)
29+
:ok,
30+
@command.run([context[:opts][:node]], context[:opts])
5631
)
5732
end
5833

59-
test "run: targeting an unknown queue returns an error", context do
60-
assert match?(
61-
{:error, _},
62-
@command.run(
63-
["stream-queue-a", "1Y"],
64-
Map.merge(context[:opts], %{vhost: "/"})
65-
)
66-
)
34+
test "banner", context do
35+
assert @command.banner(["a"], context[:opts]) =~
36+
~r/DEPRECATED. This command is a no-op./
6737
end
38+
6839
end

0 commit comments

Comments
 (0)