summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_peer_discovery_consul/priv/schema/rabbitmq_peer_discovery_consul.schema
blob: 3256d48159d6a10f72a5733c9094b4ed6ade993b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates.  All rights reserved.
%%

%% host

{mapping, "cluster_formation.consul.host", "rabbit.cluster_formation.peer_discovery_consul.consul_host", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_host",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.host", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% port

{mapping, "cluster_formation.consul.port", "rabbit.cluster_formation.peer_discovery_consul.consul_port", [
    {datatype, integer}, {validators, ["port"]}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_port",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.port", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% scheme

{mapping, "cluster_formation.consul.scheme", "rabbit.cluster_formation.peer_discovery_consul.consul_scheme", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_scheme",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.scheme", Conf, "http") of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% ACL token

{mapping, "cluster_formation.consul.acl_token", "rabbit.cluster_formation.peer_discovery_consul.consul_acl_token", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_acl_token",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.acl_token", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% cluster name

{mapping, "cluster_formation.consul.cluster_name", "rabbit.cluster_formation.peer_discovery_consul.cluster_name", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.cluster_name",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.cluster_name", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% service name

{mapping, "cluster_formation.consul.svc", "rabbit.cluster_formation.peer_discovery_consul.consul_svc", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% service address

{mapping, "cluster_formation.consul.svc_addr", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_addr", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% compute service address automatically?

{mapping, "cluster_formation.consul.svc_addr_auto", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_auto", [
    {datatype, {enum, [true, false]}}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_auto",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_addr_auto", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% service address NIC

{mapping, "cluster_formation.consul.svc_addr_nic", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_nic", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_nic",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_addr_nic", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% use (Erlang) node name when compuing service address?

{mapping, "cluster_formation.consul.svc_addr_use_nodename", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_nodename", [
    {datatype, {enum, [true, false]}}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_addr_nodename",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_addr_use_nodename", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% (optionally) append a suffix to node names retrieved from Consul

{mapping, "cluster_formation.consul.domain_suffix", "rabbit.cluster_formation.peer_discovery_consul.consul_domain", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_domain",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.domain_suffix", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% include nodes with warnings?

{mapping, "cluster_formation.consul.include_nodes_with_warnings", "rabbit.cluster_formation.peer_discovery_consul.include_nodes_with_warnings", [
    {datatype, {enum, [true, false]}}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_include_nodes_with_warnings",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.include_nodes_with_warnings", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% service (RabbitMQ node) port

{mapping, "cluster_formation.consul.svc_port", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_port", [
    {datatype, integer}, {validators, ["port"]}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_port",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_port", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.



%% service check TTL

{mapping, "cluster_formation.consul.svc_ttl", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_ttl", [
    {datatype, integer}, {validators, ["non_negative_integer"]}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_ttl",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_ttl", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% should a node in warning state be deregister by Consul after a period of time?

{mapping, "cluster_formation.consul.deregister_after", "rabbit.cluster_formation.peer_discovery_consul.consul_deregister_after", [
    {datatype, integer}, {validators, ["non_negative_integer"]}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_deregister_after",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.deregister_after", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.


%% use long node names?

{mapping, "cluster_formation.consul.use_longname", "rabbit.cluster_formation.peer_discovery_consul.consul_use_longname", [
    {datatype, {enum, [true, false]}}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_use_longname",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.use_longname", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.

%% service tags

{mapping, "cluster_formation.consul.svc_tags", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_tags", [
    {datatype, {enum, [none]}}
]}.

{mapping, "cluster_formation.consul.svc_tags.$name", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_tags", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_tags",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_tags", Conf, undefined) of
        none -> [];
        _ ->
            Pairs = cuttlefish_variable:filter_by_prefix("cluster_formation.consul.svc_tags", Conf),
            [V || {_, V} <- Pairs]
    end
end}.

%% service metadata

{mapping, "cluster_formation.consul.svc_meta", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_meta", [
    {datatype, {enum, [none]}}
]}.

{mapping, "cluster_formation.consul.svc_meta.$name", "rabbit.cluster_formation.peer_discovery_consul.consul_svc_meta", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_svc_meta",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.svc_meta", Conf, undefined) of
        none -> [];
        _    ->
          Pairs = cuttlefish_variable:filter_by_prefix("cluster_formation.consul.svc_meta", Conf),
          [{list_to_binary(lists:last(Segments)), list_to_binary(V)} || {Segments, V} <- Pairs]
    end
end}.

%% lock key prefix

{mapping, "cluster_formation.consul.lock_prefix", "rabbit.cluster_formation.peer_discovery_consul.consul_lock_prefix", [
    {datatype, string}
]}.

{translation, "rabbit.cluster_formation.peer_discovery_consul.consul_lock_prefix",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.lock_prefix", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.

%% lock acquisition timeout

{mapping, "cluster_formation.consul.lock_wait_time", "rabbit.cluster_formation.peer_discovery_consul.lock_wait_time", [
    {datatype, integer}, {validators, ["non_negative_integer"]}
]}.

{mapping, "cluster_formation.consul.lock_timeout", "rabbit.cluster_formation.peer_discovery_consul.lock_wait_time", [
    {datatype, integer}, {validators, ["non_negative_integer"]}
]}.

%% an alias for lock acquisition timeout to be consistent with the etcd backend

{translation, "rabbit.cluster_formation.peer_discovery_consul.lock_wait_time",
fun(Conf) ->
    case cuttlefish:conf_get("cluster_formation.consul.lock_timeout", Conf, undefined) of
        undefined ->
            case cuttlefish:conf_get("cluster_formation.consul.lock_wait_time", Conf, undefined) of
                    undefined -> cuttlefish:unset();
                    Value     -> Value
                end;
        Value -> Value
    end
end}.