redis-api-update
Some checks failed
deploy / deploy (push) Failing after 4s

This commit is contained in:
Untone 2024-06-06 13:33:25 +03:00
parent d479e69193
commit d14e5457f3
3 changed files with 391 additions and 443 deletions

825
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -10,12 +10,12 @@ futures = "0.3.30"
serde_json = "1.0.115" serde_json = "1.0.115"
actix-web = "4.5.1" actix-web = "4.5.1"
reqwest = { version = "0.12.3", features = ["json"] } reqwest = { version = "0.12.3", features = ["json"] }
sentry = { version = "0.32.2", features = ["tokio"] } sentry = { version = "0.34.0", features = ["tokio"] }
uuid = { version = "1.8.0", features = ["v4"] } uuid = { version = "1.8.0", features = ["v4"] }
redis = { version = "0.25.3", features = ["tokio-comp"] } redis = { version = "0.25.3", features = ["tokio-comp"] }
tokio = { version = "1.37.0", features = ["full"] } tokio = { version = "1.37.0", features = ["full"] }
serde = { version = "1.0.197", features = ["derive"] } serde = { version = "1.0.197", features = ["derive"] }
sentry-actix = "0.32.2" sentry-actix = "0.34.0"
[[bin]] [[bin]]
name = "presence" name = "presence"

View File

@ -57,7 +57,7 @@ async fn connect_handler(
ErrorUnauthorized("Unauthorized") ErrorUnauthorized("Unauthorized")
})?; })?;
let mut con = state.redis.get_async_connection().await.map_err(|e| { let mut con = state.redis.get_multiplexed_async_connection().await.map_err(|e| {
eprintln!("Failed to get async connection: {}", e); eprintln!("Failed to get async connection: {}", e);
ServerError("Internal Server Error") ServerError("Internal Server Error")
})?; })?;
@ -80,8 +80,7 @@ async fn connect_handler(
let (tx, rx) = broadcast::channel(100); let (tx, rx) = broadcast::channel(100);
let state_clone = state.clone(); let state_clone = state.clone();
let handle = tokio::spawn(async move { let handle = tokio::spawn(async move {
let conn = state_clone.redis.get_async_connection().await.unwrap(); let mut pubsub = state_clone.redis.get_async_pubsub().await.unwrap();
let mut pubsub = conn.into_pubsub();
let followers_channel = format!("follower:{}", listener_id); let followers_channel = format!("follower:{}", listener_id);
pubsub.subscribe(followers_channel.clone()).await.unwrap(); pubsub.subscribe(followers_channel.clone()).await.unwrap();
println!("'{}' pubsub subscribed", followers_channel); println!("'{}' pubsub subscribed", followers_channel);