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) 2007-2021 VMware, Inc. or its affiliates.  All rights reserved.
6%%
7
8-module(rabbit_queue_location_client_local).
9-behaviour(rabbit_queue_master_locator).
10
11-include_lib("rabbit_common/include/rabbit.hrl").
12-include("amqqueue.hrl").
13
14-export([description/0, queue_master_location/1]).
15
16-rabbit_boot_step({?MODULE,
17                   [{description, "locate queue master client local"},
18                    {mfa,         {rabbit_registry, register,
19                                   [queue_master_locator,
20                                    <<"client-local">>, ?MODULE]}},
21                    {requires,    rabbit_registry},
22                    {enables,     kernel_ready}]}).
23
24
25%%---------------------------------------------------------------------------
26%% Queue Master Location Callbacks
27%%---------------------------------------------------------------------------
28
29description() ->
30    [{description, <<"Locate queue master node as the client local node">>}].
31
32queue_master_location(Q) when ?is_amqqueue(Q) ->
33    %% unlike with other locator strategies we do not check node maintenance
34    %% status for two reasons:
35    %%
36    %% * nodes in maintenance mode will drop their client connections
37    %% * with other strategies, if no nodes are available, the current node
38    %%   is returned but this strategy already does just that
39    {ok, node()}.
40