aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/sellershut/Cargo.toml2
-rw-r--r--crates/sellershut/src/config/cache/mod.rs39
2 files changed, 14 insertions, 27 deletions
diff --git a/crates/sellershut/Cargo.toml b/crates/sellershut/Cargo.toml
index caf6fd0..df619f8 100644
--- a/crates/sellershut/Cargo.toml
+++ b/crates/sellershut/Cargo.toml
@@ -19,7 +19,7 @@ secrecy = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
sh-util = { workspace = true, features = ["cache"] }
-sqlx = { workspace = true, features = ["migrate"] }
+sqlx = { workspace = true, features = ["migrate", "runtime-tokio"] }
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] }
toml = "1.1.2"
tracing.workspace = true
diff --git a/crates/sellershut/src/config/cache/mod.rs b/crates/sellershut/src/config/cache/mod.rs
index 136c3a4..525b3aa 100644
--- a/crates/sellershut/src/config/cache/mod.rs
+++ b/crates/sellershut/src/config/cache/mod.rs
@@ -86,12 +86,8 @@ impl CacheConfig {
cache_password: higher.cache_password.or(self.cache_password),
cache_database: higher.cache_database.or(self.cache_database),
cache_service_name: higher.cache_service_name.or(self.cache_service_name),
- cache_tls_mode_secure: higher
- .cache_tls_mode_secure
- .or(self.cache_tls_mode_secure),
- cache_use_resp3: higher
- .cache_use_resp3
- .or(self.cache_use_resp3),
+ cache_tls_mode_secure: higher.cache_tls_mode_secure.or(self.cache_tls_mode_secure),
+ cache_use_resp3: higher.cache_use_resp3.or(self.cache_use_resp3),
}
}
@@ -119,20 +115,15 @@ impl CacheConfig {
self.cache_mode.unwrap_or(CacheMode::Standalone)
}
- pub fn url(&self) -> anyhow::Result<String> {
+ pub fn url(&self) -> anyhow::Result<String> {
if let Some(url) = &self.cache_url {
return Ok(url.clone());
}
match self.mode() {
CacheMode::Standalone => {
- let host = self
- .cache_host
- .as_deref()
- .context("cache.host")?;
- let port = self
- .cache_port
- .context("cache.port")?;
+ let host = self.cache_host.as_deref().context("cache.host")?;
+ let port = self.cache_port.context("cache.port")?;
let db = self.cache_database.unwrap_or(0);
let auth = match (&self.cache_username, &self.cache_password) {
@@ -145,10 +136,7 @@ impl CacheConfig {
Ok(format!("redis://{}{}:{}/{}", auth, host, port, db))
}
CacheMode::Clustered | CacheMode::Sentinel => {
- self.cache_nodes
- .first()
- .cloned()
- .context("cache.nodes[0]")
+ self.cache_nodes.first().cloned().context("cache.nodes[0]")
}
}
}
@@ -180,10 +168,9 @@ impl TryFrom<&CacheConfig> for SentinelConfig {
}
Ok(SentinelConfig {
- service_name: value
- .cache_service_name
- .clone()
- .ok_or(CacheConfigConversionError::MissingField("cache.service_name"))?,
+ service_name: value.cache_service_name.clone().ok_or(
+ CacheConfigConversionError::MissingField("cache.service_name"),
+ )?,
redis_tls_mode_secure: value.cache_tls_mode_secure.unwrap_or(false),
redis_db: value.cache_database.map(i64::from),
redis_username: value
@@ -211,15 +198,15 @@ impl TryFrom<&CacheConfig> for RedisVariant {
type Error = anyhow::Error;
fn try_from(value: &CacheConfig) -> Result<Self, Self::Error> {
- let s = SentinelConfig::try_from(value)?;
-
match value.mode() {
CacheMode::Standalone => Ok(RedisVariant::NonClustered),
CacheMode::Clustered => Ok(RedisVariant::Clustered),
- CacheMode::Sentinel => Ok(RedisVariant::Sentinel(s)),
+ CacheMode::Sentinel => {
+ let s = SentinelConfig::try_from(value)?;
+ Ok(RedisVariant::Sentinel(s))
+ }
}
}
-
}
impl TryFrom<CacheConfig> for sh_util::cache::RedisVariant {