mod consumer_progress_sub_command;
mod consumer_status_sub_command;
mod consumer_sub_command;
mod delete_subscription_group_sub_command;
mod get_consumer_config_sub_command;
mod set_consume_mode_sub_command;
mod start_monitoring_sub_command;
mod update_sub_group_list_sub_command;
mod update_sub_group_sub_command;
use clap::Subcommand;
use rocketmq_error::Result as CanonicalResult;
use crate::commands::consumer::consumer_progress_sub_command::ConsumerProgressSubCommand;
use crate::commands::consumer::consumer_status_sub_command::ConsumerStatusSubCommand;
use crate::commands::consumer::consumer_sub_command::ConsumerSubCommand;
use crate::commands::consumer::delete_subscription_group_sub_command::DeleteSubscriptionGroupSubCommand;
use crate::commands::consumer::get_consumer_config_sub_command::GetConsumerConfigSubCommand;
use crate::commands::consumer::set_consume_mode_sub_command::SetConsumeModeSubCommand;
use crate::commands::consumer::start_monitoring_sub_command::StartMonitoringSubCommand;
use crate::commands::consumer::update_sub_group_list_sub_command::UpdateSubGroupListSubCommand;
use crate::commands::consumer::update_sub_group_sub_command::UpdateSubGroupSubCommand;
use crate::commands::CommandExecute;
#[derive(Subcommand)]
pub enum ConsumerCommands {
#[command(
name = "consumerStatus",
about = "Query and display consumer's internal data structures, including subscription information, queue allocation, consumption mode, and runtime information.",
long_about = None,
)]
ConsumerStatus(ConsumerStatusSubCommand),
#[command(
name = "consumer",
about = "Query consumer's connection, status, etc.",
long_about = None,
)]
Consumer(ConsumerSubCommand),
#[command(
name = "deleteSubGroup",
about = "Delete subscription group",
long_about = r#"Delete subscription group from broker."#
)]
DeleteSubscriptionGroup(DeleteSubscriptionGroupSubCommand),
#[command(
name = "getConsumerConfig",
about = "Get consumer config by subscription group name.",
long_about = None,
)]
GetConsumerConfig(GetConsumerConfigSubCommand),
#[command(
name = "setConsumeMode",
about = "Set consume message mode. pull/pop etc.",
long_about = None,
)]
SetConsumeMode(SetConsumeModeSubCommand),
#[command(
name = "startMonitoring",
about = "Start Monitoring.",
long_about = None,
)]
StartMonitoring(StartMonitoringSubCommand),
#[command(
name = "updateSubGroupList",
about = "Create or update subscription groups in batch.",
long_about = None,
)]
UpdateSubGroupList(UpdateSubGroupListSubCommand),
#[command(
name = "updateSubGroup",
about = "Update or create subscription group.",
long_about = None,
)]
UpdateSubGroup(UpdateSubGroupSubCommand),
#[command(
name = "consumerProgress",
about = "Query consumer progress or speed.",
long_about = None
)]
QueryConsumer(ConsumerProgressSubCommand),
}
impl CommandExecute for ConsumerCommands {
async fn execute(
&self,
credentials: Option<rocketmq_admin_core::core::security::AdminCredentials>,
client_runtime: std::sync::Arc<rocketmq_admin_core::client_adapter::ClientRuntime>,
) -> CanonicalResult<()> {
match self {
ConsumerCommands::ConsumerStatus(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::Consumer(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::DeleteSubscriptionGroup(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::GetConsumerConfig(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::SetConsumeMode(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::StartMonitoring(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::UpdateSubGroupList(cmd) => cmd.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::UpdateSubGroup(value) => value.execute(credentials, client_runtime.clone()).await,
ConsumerCommands::QueryConsumer(value) => value.execute(credentials, client_runtime.clone()).await,
}
}
}