mod allocate_mq_sub_command;
mod delete_topic_sub_command;
mod remapping_static_topic_sub_command;
mod topic_cluster_sub_command;
mod topic_list_sub_command;
mod topic_route_sub_command;
mod topic_status_sub_command;
mod update_order_conf_sub_command;
mod update_static_topic_sub_command;
mod update_topic_list_sub_command;
mod update_topic_perm_sub_command;
mod update_topic_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::topic::allocate_mq_sub_command::AllocateMQSubCommand;
use crate::commands::topic::delete_topic_sub_command::DeleteTopicSubCommand;
use crate::commands::topic::remapping_static_topic_sub_command::RemappingStaticTopicSubCommand;
use crate::commands::topic::topic_cluster_sub_command::TopicClusterSubCommand;
use crate::commands::topic::topic_list_sub_command::TopicListSubCommand;
use crate::commands::topic::topic_route_sub_command::TopicRouteSubCommand;
use crate::commands::topic::topic_status_sub_command::TopicStatusSubCommand;
use crate::commands::topic::update_order_conf_sub_command::UpdateOrderConfSubCommand;
use crate::commands::topic::update_static_topic_sub_command::UpdateStaticTopicSubCommand;
use crate::commands::topic::update_topic_list_sub_command::UpdateTopicListSubCommand;
use crate::commands::topic::update_topic_perm_sub_command::UpdateTopicPermSubCommand;
use crate::commands::topic::update_topic_sub_command::UpdateTopicSubCommand;
#[derive(Subcommand)]
pub enum TopicCommands {
#[command(
name = "allocateMQ",
about = "Allocate memory space for each topic",
long_about = r#"Allocate memory space for each topic, which is used to allocate the memory
space of the topic when the topic is created. The default value is 1. If you want to allocate
more memory space, you can use this command to allocate it."#
)]
AllocateMQ(AllocateMQSubCommand),
#[command(
name = "deleteTopic",
about = "Delete topic",
long_about = r#"Delete topic from broker and NameServer."#
)]
DeleteTopic(DeleteTopicSubCommand),
#[command(
name = "remappingStaticTopic",
about = "Remapping static topic",
long_about = r#"Remapping static topic to different brokers or clusters."#
)]
RemappingStaticTopic(RemappingStaticTopicSubCommand),
#[command(
name = "topicClusterList",
about = "Get cluster info for topic",
long_about = r#"Get cluster info for a given topic. This command queries which clusters contain the specified topic."#
)]
TopicCluster(TopicClusterSubCommand),
#[command(
name = "topicList",
about = "Get topic list",
long_about = r#"Fetch all topic list from name server."#
)]
TopicList(TopicListSubCommand),
#[command(
name = "topicRoute",
about = "Examine topic route info",
long_about = r#"Examine topic route info."#
)]
TopicRoute(TopicRouteSubCommand),
#[command(
name = "topicStatus",
about = "Examine topic status info",
long_about = r#"Examine topic status info."#
)]
TopicStatus(TopicStatusSubCommand),
#[command(
name = "updateOrderConf",
about = "Create or update order conf",
long_about = r#"Create, update, or delete order topic configuration."#
)]
UpdateOrderConf(UpdateOrderConfSubCommand),
#[command(
name = "updateStaticTopic",
about = "Update static topic",
long_about = r#"Update or create static topic with queue mapping."#
)]
UpdateStaticTopic(UpdateStaticTopicSubCommand),
#[command(
name = "updateTopicList",
about = "Update topic list",
long_about = "Update topic list with specified configuration."
)]
UpdateTopicList(UpdateTopicListSubCommand),
#[command(
name = "updateTopicPerm",
about = "Update topic perm.",
long_about = r#"Update topic perm."#
)]
UpdateTopicPerm(UpdateTopicPermSubCommand),
#[command(
name = "updateTopic",
about = "Update or create topic",
long_about = r#"Update or create topic with specified configuration."#
)]
UpdateTopic(UpdateTopicSubCommand),
}
impl CommandExecute for TopicCommands {
async fn execute(&self, rpc_hook: Option<Arc<dyn RPCHook>>) -> RocketMQResult<()> {
match self {
TopicCommands::AllocateMQ(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::DeleteTopic(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::RemappingStaticTopic(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::TopicCluster(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::TopicList(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::TopicRoute(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::TopicStatus(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::UpdateOrderConf(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::UpdateStaticTopic(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::UpdateTopicList(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::UpdateTopicPerm(cmd) => cmd.execute(rpc_hook).await,
TopicCommands::UpdateTopic(cmd) => cmd.execute(rpc_hook).await,
}
}
}