1%% This Source Code Form is subject to the terms of the Mozilla Public
2%% License, v. 2.0. If a copy of the MPL was not distributed with this
3%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
4%%
5%% Copyright (c) 2010-2021 VMware, Inc. or its affiliates.  All rights reserved.
6%%
7
8-module(rabbit_mirror_queue_mode_all).
9
10-include_lib("rabbit_common/include/rabbit.hrl").
11
12-behaviour(rabbit_mirror_queue_mode).
13
14-export([description/0, suggested_queue_nodes/5, validate_policy/1]).
15
16-rabbit_boot_step({?MODULE,
17                   [{description, "mirror mode all"},
18                    {mfa,         {rabbit_registry, register,
19                                   [ha_mode, <<"all">>, ?MODULE]}},
20                    {requires,    rabbit_registry},
21                    {enables,     kernel_ready}]}).
22
23description() ->
24    [{description, <<"Mirror queue to all nodes">>}].
25
26suggested_queue_nodes(_Params, MNode, _SNodes, _SSNodes, Poss) ->
27    {MNode, Poss -- [MNode]}.
28
29validate_policy(none) ->
30    ok;
31validate_policy(_Params) ->
32    {error, "ha-mode=\"all\" does not take parameters", []}.
33