Skip to content

Commit fb6f15c

Browse files
committed
Add some models for redis-cli
1 parent b7bd98a commit fb6f15c

File tree

7 files changed

+257
-0
lines changed

7 files changed

+257
-0
lines changed

redis-cli/src/conf.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod cli_config;
2+
mod cli_conn_info;
3+
mod cli_ssl_config;
4+
mod cluster_manager_command;
5+
pub mod consts;
6+
mod pref;
7+
8+
pub use cli_config::CliConfig;
9+
pub use cli_conn_info::CliConnInfo;
10+
pub use cli_ssl_config::CliSSLConfig;
11+
pub use cluster_manager_command::ClusterManagerCommand;
12+
pub use pref::Pref;

redis-cli/src/conf/cli_config.rs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
use super::CliSSLConfig;
2+
use super::CliConnInfo;
3+
use super::ClusterManagerCommand;
4+
use super::consts;
5+
6+
pub struct CliConfig {
7+
pub conn_info: CliConnInfo,
8+
pub host_socket: String,
9+
pub tls: i32,
10+
pub ssl_config: CliSSLConfig,
11+
pub repeat: i64,
12+
pub interval: i64,
13+
pub db_num: i32,
14+
pub interactive: i32,
15+
pub shutdown: i32,
16+
pub monitor_mode: i32,
17+
pub pub_sub_mode: i32,
18+
pub blocking_state_aborted: i32,
19+
pub latency_mode: i32,
20+
pub latency_dist_mode: i32,
21+
pub latency_history: i32,
22+
pub lru_test_mode: i32,
23+
pub lru_test_sample_size: i64,
24+
pub cluster_mode: i32,
25+
pub cluster_reissue_command: i32,
26+
pub cluster_send_asking: i32,
27+
pub slave_mode: i32,
28+
pub pipe_mode: i32,
29+
pub pipe_timeout: i32,
30+
pub get_rdb_mode: i32,
31+
pub get_functions_rdb_mode: i32,
32+
pub stat_mode: i32,
33+
pub scan_mode: i32,
34+
pub intrinsic_latency_mode: i32,
35+
pub intrinsic_latency_duration: i32,
36+
pub pattern: String,
37+
pub rdb_filename: String,
38+
pub big_keys: i32,
39+
pub mem_keys: i32,
40+
pub mem_keys_samples: u32,
41+
pub hot_keys: i32,
42+
pub stdin_last_arg: i32,
43+
pub stdin_tag_arg: i32,
44+
pub stdin_tag_name: String,
45+
pub ask_pass: i32,
46+
pub quoted_input: i32,
47+
pub output: i32,
48+
pub push_output: i32,
49+
pub mb_delim: String,
50+
pub cmd_delim: String,
51+
pub prompt: [char; 128],
52+
pub eval: String,
53+
pub eval_ldb: i32,
54+
pub eval_ldb_sync: i32,
55+
pub eval_ldb_end: i32,
56+
pub enable_ldb_on_eval: i32,
57+
pub last_cmd_type: i32,
58+
pub verbose: i32,
59+
pub set_errcode: i32,
60+
pub cluster_manager_command: ClusterManagerCommand,
61+
pub no_auth_warning: i32,
62+
pub resp2: i32,
63+
pub resp3: i32,
64+
pub in_multi: i32,
65+
pub pre_multi_db_num: i32,
66+
}
67+
68+
impl CliConfig {
69+
pub fn new() -> CliConfig {
70+
CliConfig {
71+
conn_info: CliConnInfo::new(),
72+
host_socket: "".to_string(),
73+
tls: 0,
74+
ssl_config: CliSSLConfig::new(),
75+
repeat: 1,
76+
interval: 0,
77+
db_num: 0,
78+
interactive: 0,
79+
shutdown: 0,
80+
monitor_mode: 0,
81+
pub_sub_mode: 0,
82+
blocking_state_aborted: 0,
83+
latency_mode: 0,
84+
latency_dist_mode: 0,
85+
latency_history: 0,
86+
lru_test_mode: 0,
87+
lru_test_sample_size: 0,
88+
cluster_mode: 0,
89+
cluster_reissue_command: 0,
90+
cluster_send_asking: 0,
91+
slave_mode: 0,
92+
pipe_mode: 0,
93+
pipe_timeout: consts::REDIS_CLI_DEFAULT_PIPE_TIMEOUT,
94+
get_rdb_mode: 0,
95+
get_functions_rdb_mode: 0,
96+
stat_mode: 0,
97+
scan_mode: 0,
98+
intrinsic_latency_mode: 0,
99+
intrinsic_latency_duration: 0,
100+
pattern: "".to_string(),
101+
rdb_filename: "".to_string(),
102+
big_keys: 0,
103+
mem_keys: 0,
104+
mem_keys_samples: 0,
105+
hot_keys: 0,
106+
stdin_last_arg: 0,
107+
stdin_tag_arg: 0,
108+
stdin_tag_name: "".to_string(),
109+
ask_pass: 0,
110+
quoted_input: 0,
111+
output: consts::OUTPUT_STANDARD,
112+
push_output: 1,
113+
mb_delim: "\n".to_string(),
114+
cmd_delim: "\n".to_string(),
115+
prompt: [' '; 128],
116+
eval: "".to_string(),
117+
eval_ldb: 0,
118+
eval_ldb_sync: 0,
119+
eval_ldb_end: 0,
120+
enable_ldb_on_eval: 0,
121+
last_cmd_type: -1,
122+
verbose: 0,
123+
set_errcode: 0,
124+
cluster_manager_command: ClusterManagerCommand::new(),
125+
no_auth_warning: 0,
126+
resp2: 0,
127+
resp3: 0,
128+
in_multi: 0,
129+
pre_multi_db_num: 0,
130+
}
131+
}
132+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pub struct CliConnInfo {
2+
pub host_ip: String,
3+
pub host_port: i32,
4+
pub input_db_num: i32,
5+
pub auth: String,
6+
pub user: String,
7+
}
8+
9+
impl CliConnInfo {
10+
pub fn new() -> CliConnInfo {
11+
CliConnInfo {
12+
host_ip: "127.0.0.1".to_string(),
13+
host_port: 6379,
14+
input_db_num: 0,
15+
auth: "".to_string(),
16+
user: "".to_string(),
17+
}
18+
}
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
pub struct CliSSLConfig {
2+
pub sni: String,
3+
pub ca_cert: String,
4+
pub ca_cert_dir: String,
5+
pub skip_cert_verify: i32,
6+
pub cert: String,
7+
pub key: String,
8+
pub ciphers: String,
9+
pub cipher_suites: String,
10+
}
11+
12+
impl CliSSLConfig {
13+
pub fn new() -> CliSSLConfig {
14+
CliSSLConfig {
15+
sni: "".to_string(),
16+
ca_cert: "".to_string(),
17+
ca_cert_dir: "".to_string(),
18+
skip_cert_verify: 0,
19+
cert: "".to_string(),
20+
key: "".to_string(),
21+
ciphers: "".to_string(),
22+
cipher_suites: "".to_string(),
23+
}
24+
}
25+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use super::consts;
2+
3+
pub struct ClusterManagerCommand {
4+
pub name: String,
5+
pub argc: i32,
6+
pub argv: Vec<String>,
7+
pub stdin_arg: String,
8+
pub flags: i32,
9+
pub replicas: i32,
10+
pub from: String,
11+
pub to: String,
12+
pub weight: Vec<String>,
13+
pub weight_argc: i32,
14+
pub master_id: String,
15+
pub slots: i32,
16+
pub timeout: i32,
17+
pub pipeline: i32,
18+
pub threshold: f32,
19+
pub backup_dir: String,
20+
pub from_user: String,
21+
pub from_pass: String,
22+
pub from_ask_pass: i32,
23+
}
24+
25+
impl ClusterManagerCommand {
26+
pub fn new() -> ClusterManagerCommand {
27+
ClusterManagerCommand {
28+
name: "".to_string(),
29+
argc: 0,
30+
argv: vec![],
31+
stdin_arg: "".to_string(),
32+
flags: 0,
33+
replicas: 0,
34+
from: "".to_string(),
35+
to: "".to_string(),
36+
weight: vec![],
37+
weight_argc: 0,
38+
master_id: "".to_string(),
39+
slots: 0,
40+
timeout: consts::CLUSTER_MANAGER_MIGRATE_TIMEOUT,
41+
pipeline: consts::CLUSTER_MANAGER_MIGRATE_PIPELINE,
42+
threshold: consts::CLUSTER_MANAGER_REBALANCE_THRESHOLD,
43+
backup_dir: "".to_string(),
44+
from_user: "".to_string(),
45+
from_pass: "".to_string(),
46+
from_ask_pass: 0,
47+
}
48+
}
49+
}

redis-cli/src/conf/consts.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub const REDIS_CLI_DEFAULT_PIPE_TIMEOUT: i32 = 30;
2+
pub const CLUSTER_MANAGER_MIGRATE_TIMEOUT: i32 = 60000;
3+
pub const CLUSTER_MANAGER_MIGRATE_PIPELINE: i32 = 10;
4+
pub const CLUSTER_MANAGER_REBALANCE_THRESHOLD: f32 = 2.0;
5+
pub const CLUSTER_MANAGER_CMD_FLAG_MASTERS_ONLY: i32 = 1 << 11;
6+
pub const CLUSTER_MANAGER_CMD_FLAG_SLAVES_ONLY: i32 = 1 << 12;
7+
pub const OUTPUT_STANDARD: i32 = 0;
8+
pub const OUTPUT_RAW: i32 = 1;
9+
pub const OUTPUT_CSV: i32 = 2;
10+
pub const OUTPUT_JSON: i32 = 3;
11+
pub const OUTPUT_QUOTED_JSON: i32 = 4;

redis-cli/src/conf/pref.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub struct Pref {
2+
pub hints: i32,
3+
}
4+
5+
impl Pref {
6+
pub fn new() -> Pref {
7+
Pref { hints: 1 }
8+
}
9+
}

0 commit comments

Comments
 (0)