Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion deps/rabbit/priv/schema/rabbit.schema
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ end}.
{datatype, string}
]}.

{mapping, "default_policies.operator.$id.apply_to", "rabbit.default_policies.operator", [
{datatype, string}
]}.

{mapping, "default_policies.operator.$id.expires", "rabbit.default_policies.operator", [
{datatype, {duration, ms}}
]}.
Expand Down Expand Up @@ -815,7 +819,9 @@ end}.
end,
{["default_policies","operator",ID|T], NewV};
({["default_policies","operator",ID, "queue_pattern"], V}) ->
{["default_policies","operator",ID,"queue_pattern"], list_to_binary(V)};
{["default_policies","operator",ID, "queue_pattern"], list_to_binary(V)};
({["default_policies","operator",ID, "apply_to"], V}) ->
{["default_policies","operator",ID, "apply_to"], list_to_binary(V)};
(E) -> E
end),
case Props of
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbit/src/rabbit_classic_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
{cleanup, {rabbit_registry, unregister,
[queue, <<"classic">>]}},
{requires, rabbit_registry},
{enables, ?MODULE}]}).
{enables, [?MODULE, rabbit_policy]}]}).

-rabbit_boot_step(
{?MODULE,
Expand Down
14 changes: 9 additions & 5 deletions deps/rabbit/src/rabbit_db_vhost_defaults.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
-record(seeding_policy, {
name :: binary(),
queue_pattern = <<".*">> :: binary(),
definition = [] :: definitions()
definition = [] :: definitions(),
apply_to = <<"all">>
}).

-type seeded_user_properties() :: #{
Expand All @@ -43,9 +44,9 @@ apply(VHost, ActingUser) ->
end,
lists:foreach(
fun(P) ->
ok = rabbit_policy:set_op(VHost, P#seeding_policy.name, P#seeding_policy.queue_pattern, P#seeding_policy.definition,
undefined, undefined, ActingUser),
?LOG_INFO("Applied default operator policy to vhost '~tp': ~tp", [VHost, P])
ok = rabbit_policy:set_op(VHost, P#seeding_policy.name, P#seeding_policy.queue_pattern, P#seeding_policy.definition,
undefined, P#seeding_policy.apply_to, ActingUser),
?LOG_INFO("Applied default operator policy to vhost '~tp': ~tp", [VHost, P])
end,
list_operator_policies(VHost)
),
Expand Down Expand Up @@ -93,12 +94,15 @@ list_operator_policies(VHost) ->
case re:run(VHost, RE, [{capture, none}]) of
match ->
QPattern = proplists:get_value(<<"queue_pattern">>, Ss, <<".*">>),
ApplyTo = proplists:get_value(<<"apply_to">>, Ss, <<"all">>),
Ss1 = proplists:delete(<<"queue_pattern">>, Ss),
Ss2 = proplists:delete(<<"vhost_pattern">>, Ss1),
Ss3 = proplists:delete(<<"apply_to">>, Ss2),
{true, #seeding_policy{
name = PolicyName,
queue_pattern = QPattern,
definition = underscore_to_dash(Ss2)
apply_to = ApplyTo,
definition = underscore_to_dash(Ss3)
}};
_ ->
false
Expand Down
3 changes: 2 additions & 1 deletion deps/rabbit/src/rabbit_quorum_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
[queue, <<"quorum">>, ?MODULE]}},
{cleanup, {rabbit_registry, unregister,
[queue, <<"quorum">>]}},
{requires, rabbit_registry}]}).
{requires, rabbit_registry},
{enables, rabbit_policy}]}).

-type msg_id() :: non_neg_integer().
-type qmsg() :: {rabbit_types:r('queue'), pid(), msg_id(), boolean(),
Expand Down
3 changes: 2 additions & 1 deletion deps/rabbit/src/rabbit_stream_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
[queue, <<"stream">>, ?MODULE]}},
{cleanup, {rabbit_registry, unregister,
[queue, <<"stream">>]}},
{requires, rabbit_registry}
{requires, rabbit_registry},
{enables, rabbit_policy}
]}).

-type client() :: #stream_client{}.
Expand Down
10 changes: 3 additions & 7 deletions deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,13 @@ ssl_options.fail_if_no_peer_cert = true",
default_policies.operator.a.expires = 1h
default_policies.operator.a.queue_pattern = apple
default_policies.operator.a.vhost_pattern = banana
default_policies.operator.a.classic_queues.ha_mode = exactly
default_policies.operator.a.classic_queues.ha_params = 2
default_policies.operator.a.classic_queues.ha_sync_mode = automatic
default_policies.operator.a.apply_to = quorum_queues
default_policies.operator.a.classic_queues.queue_version = 2

",
[{rabbit, [{default_policies, [{operator, [
{<<"a">>, [{<<"expires">>, 3600000},
{<<"ha_mode">>, <<"exactly">>},
{<<"ha_params">>, 2},
{<<"ha_sync_mode">>, <<"automatic">>},
{<<"a">>, [{<<"apply_to">>,<<"quorum_queues">>},
{<<"expires">>, 3600000},
{<<"queue_pattern">>, <<"apple">>},
{<<"queue_version">>, 2},
{<<"vhost_pattern">>, "banana"}]}]}]}]}],
Expand Down
Loading