feat(redis): add configurable key namespace separator
This commit is contained in:
1 parent
14d11a9933
commit
d353d4673f
20 files changed
+64
-20
No files matched your search
@@ -60,6 +60,8 @@ pub struct ConnectionConfig {
|
||||
pub redis_sentinel_tls: bool,
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
pub redis_cluster_nodes: String,
|
||||
#[serde(default = "default_redis_key_separator", skip_serializing_if = "is_default_redis_separator")]
|
||||
pub redis_key_separator: String,
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
pub etcd_endpoints: String,
|
||||
/// Typed configuration for external tabular sources.
|
||||
@@ -196,6 +198,14 @@ fn is_false(value: &bool) -> bool {
|
||||
!*value
|
||||
}
|
||||
|
||||
pub fn default_redis_key_separator() -> String {
|
||||
":".to_string()
|
||||
}
|
||||
|
||||
fn is_default_redis_separator(value: &str) -> bool {
|
||||
value == ":"
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default)]
|
||||
@@ -337,6 +347,8 @@ struct ConnectionConfigData {
|
||||
pub redis_sentinel_tls: bool,
|
||||
#[serde(default)]
|
||||
pub redis_cluster_nodes: String,
|
||||
#[serde(default = "default_redis_key_separator")]
|
||||
pub redis_key_separator: String,
|
||||
#[serde(default)]
|
||||
pub etcd_endpoints: String,
|
||||
#[serde(default)]
|
||||
@@ -386,6 +398,7 @@ impl From<ConnectionConfigData> for ConnectionConfig {
|
||||
redis_sentinel_password: data.redis_sentinel_password,
|
||||
redis_sentinel_tls: data.redis_sentinel_tls,
|
||||
redis_cluster_nodes: data.redis_cluster_nodes,
|
||||
redis_key_separator: data.redis_key_separator,
|
||||
etcd_endpoints: data.etcd_endpoints,
|
||||
external_config: data.external_config,
|
||||
jdbc_driver_class: data.jdbc_driver_class,
|
||||
@@ -1337,8 +1350,8 @@ fn bracket_ipv6(host: &str) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
default_query_timeout_secs, default_ssh_connect_timeout_secs, ConnectionConfig, DatabaseType,
|
||||
ProxyTunnelConfig, ProxyType, TransportLayerConfig,
|
||||
default_query_timeout_secs, default_redis_key_separator, default_ssh_connect_timeout_secs, ConnectionConfig,
|
||||
DatabaseType, ProxyTunnelConfig, ProxyType, TransportLayerConfig,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -1376,6 +1389,7 @@ mod tests {
|
||||
redis_sentinel_password: String::new(),
|
||||
redis_sentinel_tls: false,
|
||||
redis_cluster_nodes: String::new(),
|
||||
redis_key_separator: default_redis_key_separator(),
|
||||
etcd_endpoints: String::new(),
|
||||
external_config: None,
|
||||
jdbc_driver_class: None,
|
||||
|
||||
Reference in new issue
Block a user