Skip to content

Commit

Permalink
'rabbitmq diagnostics check_if_metadata_store_is_initialized*': suppo…
Browse files Browse the repository at this point in the history
…rt --formatter=json
  • Loading branch information
michaelklishin committed Jan 29, 2025
1 parent 07ec1b4 commit b8fccd9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,30 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfMetadataStoreIsInitializedCom
:rabbit_misc.rpc_call(node_name, :rabbit_db, :is_init_finished, [], timeout)
end


def output(true, %{silent: true}) do
{:ok, :check_passed}
end
def output(true, %{formatter: "json"}) do
{:ok, %{"result" => "ok"}}
end
def output(true, %{node: node_name} = _options) do
{:ok, "Metadata store on node #{node_name} has completed its initialization"}
end

def output(false, %{silent: true}) do
{:error, :check_failed}
end
def output(false, %{node: node_name, formatter: "json"}) do
{:error, :check_failed,
%{
"result" => "error",
"message" => "Metadata store on node #{node_name} reports to not yet have finished initialization"
}}
end
def output(false, %{node: node_name} = _options) do
{:error,
"Metadata store on node #{node_name} reports to not yet have finished initialization"}
"Metadata store on node #{node_name} reports to not yet have finished initialization"}
end

use RabbitMQ.CLI.DefaultOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,29 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfMetadataStoreIsInitializedWit
end
end

def output(true, %{silent: true}) do
{:ok, :check_passed}
end
def output(true, %{formatter: "json"}) do
{:ok, %{"result" => "ok"}}
end
def output(true, %{node: node_name} = _options) do
{:ok, "Metadata store on node #{node_name} has completed its initialization"}
end

def output(false, %{silent: true}) do
{:error, :check_failed}
end
def output(false, %{node: node_name, formatter: "json"}) do
{:error, :check_failed,
%{
"result" => "error",
"message" => "Metadata store on node #{node_name} reports to not yet have finished initialization"
}}
end
def output(false, %{node: node_name} = _options) do
{:error,
"Metadata store on node #{node_name} reports to not yet have finished initialization"}
"Metadata store on node #{node_name} reports to not yet have finished initialization"}
end

use RabbitMQ.CLI.DefaultOutput
Expand Down

0 comments on commit b8fccd9

Please sign in to comment.