mod add_write_perm_sub_command;
mod delete_kv_config_sub_command;
mod get_namesrv_config_sub_command;
mod update_kv_config_sub_command;
mod update_namesrv_config_sub_command;
mod wipe_write_perm_sub_command;
use std::sync::Arc;
use clap::Subcommand;
use rocketmq_error::RocketMQResult;
use rocketmq_remoting::runtime::RPCHook;
use crate::commands::CommandExecute;
use crate::commands::namesrv::add_write_perm_sub_command::AddWritePermSubCommand;
use crate::commands::namesrv::delete_kv_config_sub_command::DeleteKvConfigSubCommand;
use crate::commands::namesrv::get_namesrv_config_sub_command::GetNamesrvConfigSubCommand;
use crate::commands::namesrv::update_kv_config_sub_command::UpdateKvConfigSubCommand;
use crate::commands::namesrv::update_namesrv_config_sub_command::UpdateNamesrvConfigSubCommand;
use crate::commands::namesrv::wipe_write_perm_sub_command::WipeWritePermSubCommand;
#[derive(Subcommand)]
pub enum NameServerCommands {
#[command(
name = "addWritePerm",
about = "Add write perm of broker in all name server you defined in the -n param.",
long_about = None,
)]
AddWritePerm(AddWritePermSubCommand),
#[command(
name = "deleteKvConfig",
about = "Delete KV config.",
long_about = None,
)]
DeleteKvConfig(DeleteKvConfigSubCommand),
#[command(
name = "getNamesrvConfig",
about = "Get configs of name server.",
long_about = None,
)]
GetNamesrvConfig(GetNamesrvConfigSubCommand),
#[command(
name = "updateKvConfig",
about = "Create or update KV config.",
long_about = None,
)]
UpdateKvConfig(UpdateKvConfigSubCommand),
#[command(
name = "updateNamesrvConfig",
about = "Update configs of name server.",
long_about = None,
)]
UpdateNamesrvConfig(UpdateNamesrvConfigSubCommand),
#[command(
name = "wipeWritePerm",
about = "Wipe write perm of broker in all name server you defined in the -n param.",
long_about = None,
)]
WipeWritePerm(WipeWritePermSubCommand),
}
impl CommandExecute for NameServerCommands {
async fn execute(&self, rpc_hook: Option<Arc<dyn RPCHook>>) -> RocketMQResult<()> {
match self {
NameServerCommands::AddWritePerm(value) => value.execute(rpc_hook).await,
NameServerCommands::DeleteKvConfig(value) => value.execute(rpc_hook).await,
NameServerCommands::GetNamesrvConfig(value) => value.execute(rpc_hook).await,
NameServerCommands::UpdateKvConfig(value) => value.execute(rpc_hook).await,
NameServerCommands::UpdateNamesrvConfig(value) => value.execute(rpc_hook).await,
NameServerCommands::WipeWritePerm(value) => value.execute(rpc_hook).await,
}
}
}