Skip to content

Disable the stream_plugin if stream feature flag is not enabled #3562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 14, 2021
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
22 changes: 17 additions & 5 deletions deps/rabbitmq_stream/src/rabbit_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@
-include("rabbit_stream_metrics.hrl").

start(_Type, _Args) ->
rabbit_stream_metrics:init(),
rabbit_global_counters:init([{protocol, stream}], ?PROTOCOL_COUNTERS),
rabbit_global_counters:init([{protocol, stream},
{queue_type, ?STREAM_QUEUE_TYPE}]),
rabbit_stream_sup:start_link().
FeatureFlagsEnabled = rabbit_ff_registry:list(enabled),
case maps:is_key(stream_queue, FeatureFlagsEnabled) of
true ->
rabbit_stream_metrics:init(),
rabbit_global_counters:init([{protocol, stream}], ?PROTOCOL_COUNTERS),
rabbit_global_counters:init([{protocol, stream}, {queue_type, ?STREAM_QUEUE_TYPE}]),
rabbit_stream_sup:start_link();
false ->
rabbit_log:warning(
"Unable to start the stream plugin. The stream_queue feature flag is disabled. "++
"Enable stream_queue feature flag then disable and re-enable the rabbitmq_stream plugin. ",
"See https://www.rabbitmq.com/feature-flags.html to learn more",
[]),
{ok, self()}
end.



tls_host() ->
case application:get_env(rabbitmq_stream, advertised_tls_host,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
-include_lib("rabbit_common/include/rabbit.hrl").

dispatcher() ->
[{"/stream/connections/:vhost/:connection/consumers", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/connections/:vhost/:connection/consumers", ?MODULE, []}];
false -> []
end.


web_ui() ->
[].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
-include_lib("rabbit_common/include/rabbit.hrl").

dispatcher() ->
[{"/stream/connections/:vhost/:connection", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/connections/:vhost/:connection", ?MODULE, []}];
false -> []
end.


web_ui() ->
[].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
-include_lib("rabbit_common/include/rabbit.hrl").

dispatcher() ->
[{"/stream/connections/:vhost/:connection/publishers", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/connections/:vhost/:connection/publishers", ?MODULE, []}];
false -> []
end.


web_ui() ->
[].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@
-include_lib("rabbitmq_management_agent/include/rabbit_mgmt_records.hrl").

dispatcher() ->
[{"/stream/connections", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/connections", ?MODULE, []}];
false -> []
end.


web_ui() ->
[{javascript, <<"stream.js">>}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{javascript, <<"stream.js">>}];
false -> rabbit_log:warning(
"Unable to show the stream management plugin. The stream_queue feature flag is disabled. "++
"Enable stream_queue feature flag then disable and re-enable the rabbitmq_stream_management plugin. ",
"See https://www.rabbitmq.com/feature-flags.html to learn more",
[]),
[]
end.

%%--------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
-include_lib("amqp_client/include/amqp_client.hrl").

dispatcher() ->
[{"/stream/connections/:vhost", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/connections/:vhost", ?MODULE, []}];
false -> []
end.

web_ui() ->
[].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
-include_lib("rabbit_common/include/rabbit.hrl").

dispatcher() ->
[{"/stream/consumers", ?MODULE, []},
{"/stream/consumers/:vhost", ?MODULE, []}].
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/consumers", ?MODULE, []},
{"/stream/consumers/:vhost", ?MODULE, []}];
false -> []
end.

web_ui() ->
[].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

-export([keep_stream_connections/1,
keep_tracked_stream_connections/1,
is_stream_connection/1]).
is_stream_connection/1,
is_feature_flag_enabled/0]).

-include_lib("rabbit_common/include/rabbit.hrl").

Expand All @@ -31,3 +32,7 @@ keep_tracked_stream_connections(Connections) ->
false
end,
Connections).

is_feature_flag_enabled() ->
FeatureFlagsEnabled = rabbit_ff_registry:list(enabled),
maps:is_key(stream_queue, FeatureFlagsEnabled).
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
-include_lib("rabbit_common/include/rabbit.hrl").

dispatcher() ->
[{"/stream/publishers", ?MODULE, []},
case rabbit_stream_management_utils:is_feature_flag_enabled() of
true -> [{"/stream/publishers", ?MODULE, []},
{"/stream/publishers/:vhost", ?MODULE, []},
{"/stream/publishers/:vhost/:queue", ?MODULE, []}].
{"/stream/publishers/:vhost/:queue", ?MODULE, []}];
false -> []
end.

web_ui() ->
[].
Expand Down