redis_event/
config.rs

1/*!
2定义[`RedisListener`]所需的各项配置信息
3
4[`RedisListener`]: trait.RedisListener.html
5*/
6use std::time::Duration;
7
8/// 配置信息结构体定义
9#[derive(Debug)]
10pub struct Config {
11    /// 是否跳过整个RDB不进行处理,直接进入AOF处理
12    pub is_discard_rdb: bool,
13    /// 是否需要处理AOF, 如为false, 处理完RDB后`RedisListener`将中止
14    pub is_aof: bool,
15    /// Redis的地址
16    pub host: String,
17    /// Redis的端口
18    pub port: u16,
19    /// Redis的用户名
20    pub username: String,
21    /// Redis的密码
22    pub password: String,
23    /// Replication ID
24    pub repl_id: String,
25    /// Replication Offset
26    pub repl_offset: i64,
27    /// Read Timeout
28    pub read_timeout: Option<Duration>,
29    /// Write Timeout
30    pub write_timeout: Option<Duration>,
31    /// 是否启用TLS
32    pub is_tls_enabled: bool,
33    /// 是否信任无效的证书和域名
34    pub is_tls_insecure: bool,
35    /// 客户端认证所使用的Key
36    pub identity: Option<String>,
37    /// 解密Key所需的密码
38    pub identity_passwd: Option<String>,
39}
40
41impl Clone for Config {
42    fn clone(&self) -> Self {
43        Config {
44            is_discard_rdb: self.is_discard_rdb,
45            is_aof: self.is_aof,
46            host: self.host.clone(),
47            port: self.port.clone(),
48            username: self.username.clone(),
49            password: self.password.clone(),
50            repl_id: self.repl_id.clone(),
51            repl_offset: self.repl_offset,
52            read_timeout: self.read_timeout,
53            write_timeout: self.write_timeout,
54            is_tls_enabled: self.is_tls_enabled,
55            is_tls_insecure: self.is_tls_insecure,
56            identity: self.identity.clone(),
57            identity_passwd: self.identity_passwd.clone(),
58        }
59    }
60}