mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 09:04:55 +00:00
* chore(labrinth): bump to redis 1.4.1 * feat(labrinth): redis cluster * chore: cleanup * feat(labrinth): cache locking * fix(labrinth): clippy * chore(labrinth): cleanup env, remove postcard support * chore(ci): fix test env for labrinth * chore(labrinth): bump all key versions * chore(labrinth): improve redis key identities handling * chore(labrinth): simplify deadline handling * chore(labrinth): remove unused lease tracking * chore(labrinth): remove distributed cache locking for now * chore(labrinth): improve redis backend init error * feat(labrinth): expose redis read replica strategy * chore(ci): remove other connection mode tests * chore: split xredis crate * feat(xredis): primaries routing * chore: tombi fmt * chore: clippy * chore: update query cache
38 lines
958 B
Rust
38 lines
958 B
Rust
use redis::{FromRedisValue, RedisResult, ToRedisArgs};
|
|
use tracing::{Instrument, info_span};
|
|
|
|
pub(crate) fn cmd(name: &str) -> InstrumentedCmd {
|
|
InstrumentedCmd {
|
|
inner: redis::cmd(name),
|
|
name: name.to_string(),
|
|
}
|
|
}
|
|
|
|
pub(crate) struct InstrumentedCmd {
|
|
inner: redis::Cmd,
|
|
name: String,
|
|
}
|
|
|
|
impl InstrumentedCmd {
|
|
#[inline]
|
|
pub fn arg<T: ToRedisArgs>(&mut self, arg: T) -> &mut Self {
|
|
self.inner.arg(arg);
|
|
self
|
|
}
|
|
|
|
#[inline]
|
|
pub async fn query_async<T: FromRedisValue>(
|
|
&self,
|
|
con: &mut impl redis::aio::ConnectionLike,
|
|
) -> RedisResult<T> {
|
|
let span = info_span!(
|
|
"cmd.query_async",
|
|
// <https://opentelemetry.io/docs/specs/semconv/db/redis/>
|
|
db.system.name = "redis",
|
|
db.operation.name = self.name,
|
|
db.query.text = self.name,
|
|
);
|
|
self.inner.query_async(con).instrument(span).await
|
|
}
|
|
}
|