forked from mxsm/rocketmq-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.rs
More file actions
110 lines (98 loc) · 3.86 KB
/
message.rs
File metadata and controls
110 lines (98 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2023 The RocketMQ Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub mod check_msg_send_rt_sub_command;
pub mod decode_message_id_sub_command;
pub mod dump_compaction_log_sub_command;
pub mod print_message_sub_command;
pub mod print_msg_by_queue_sub_command;
pub mod query_msg_by_id_sub_command;
pub mod query_msg_by_key_sub_command;
pub mod send_message_sub_command;
use std::sync::Arc;
use clap::Subcommand;
use rocketmq_error::RocketMQResult;
use rocketmq_remoting::runtime::RPCHook;
use crate::commands::message::check_msg_send_rt_sub_command::CheckMsgSendRTSubCommand;
use crate::commands::message::decode_message_id_sub_command::DecodeMessageIdSubCommand;
use crate::commands::message::dump_compaction_log_sub_command::DumpCompactionLogSubCommand;
use crate::commands::message::print_message_sub_command::PrintMessageSubCommand;
use crate::commands::message::print_msg_by_queue_sub_command::PrintMsgByQueueSubCommand;
use crate::commands::message::query_msg_by_id_sub_command::QueryMsgByIdSubCommand;
use crate::commands::message::query_msg_by_key_sub_command::QueryMsgByKeySubCommand;
use crate::commands::message::send_message_sub_command::SendMessageSubCommand;
use crate::commands::CommandExecute;
#[derive(Subcommand)]
pub enum MessageCommands {
#[command(
name = "checkMsgSendRT",
about = "Check message send response time.",
long_about = None,
)]
CheckMsgSendRT(CheckMsgSendRTSubCommand),
#[command(
name = "decodeMessageId",
about = "Decode unique message ID.",
long_about = None,
)]
DecodeMessageId(DecodeMessageIdSubCommand),
#[command(
name = "dumpCompactionLog",
about = "Parse compaction log to message.",
long_about = None,
)]
DumpCompactionLog(DumpCompactionLogSubCommand),
#[command(
name = "printMessage",
about = "Print Message Detail.",
long_about = None,
)]
PrintMessage(PrintMessageSubCommand),
#[command(
name = "printMsgByQueue",
about = "Print Message Detail by queueId.",
long_about = None,
)]
PrintMsgByQueue(PrintMsgByQueueSubCommand),
#[command(
name = "queryMsgById",
about = "Query message by message ID.",
long_about = None,
)]
QueryMsgById(QueryMsgByIdSubCommand),
#[command(
name = "queryMsgByKey",
about = "Query Message by Key.",
long_about = None,
)]
QueryMsgByKey(QueryMsgByKeySubCommand),
#[command(
name = "sendMessage",
about = "Send a message.",
long_about = None,
)]
SendMessage(SendMessageSubCommand),
}
impl CommandExecute for MessageCommands {
async fn execute(&self, rpc_hook: Option<Arc<dyn RPCHook>>) -> RocketMQResult<()> {
match self {
MessageCommands::CheckMsgSendRT(value) => value.execute(rpc_hook).await,
MessageCommands::DecodeMessageId(value) => value.execute(rpc_hook).await,
MessageCommands::DumpCompactionLog(value) => value.execute(rpc_hook).await,
MessageCommands::PrintMessage(value) => value.execute(rpc_hook).await,
MessageCommands::PrintMsgByQueue(value) => value.execute(rpc_hook).await,
MessageCommands::QueryMsgByKey(value) => value.execute(rpc_hook).await,
MessageCommands::SendMessage(value) => value.execute(rpc_hook).await,
}
}
}