diff --git a/crates/service/websocket_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs b/crates/service/websocket_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs index 34457d23a8..249def5a5b 100644 --- a/crates/service/websocket_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs +++ b/crates/service/websocket_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs @@ -201,30 +201,25 @@ impl StreamHandler> for ObsGatewayWebSock // TODO: This should be done *BEFORE* PubSub self.write_obs_active().unwrap(); - // TODO: Redis LPOP supports a number of list items to pop, but apparently it's broken in the - // Rust API bindings (?). When I last deployed this, though the code compiled, it broke. - // It would be a nice optimization to make. + // TODO: Error handling + if let Some(tts_job_token) = self.tts_job_token_queue.dequeue_token().unwrap() { + let tts_job_tokens = Some(vec![tts_job_token]); - let redis_key = RedisKeys::twitch_tts_job_queue(&self.twitch_user_id.get_str()); + warn!("Sending job tokens: {:?}", tts_job_tokens); - let lookup_result : Option = redis.lpop(&redis_key).unwrap(); // TODO: Error handling - let mut values = Vec::new(); - - if let Some(v) = lookup_result.as_deref() { - values.push(v.to_string()); let payload = FrontendEventPayload { response_type: TtsEvent, - tts_job_tokens: Some(values), + tts_job_tokens, }; match serde_json::to_string(&payload) { - Ok(json) => { - ctx.text(json); - }, + Ok(json) => ctx.text(json), Err(e) => { error!("Error with JSON payload: {:?}", e); } } + + return; } match msg { diff --git a/crates/service/websocket_gateway/src/endpoints_ws/threads/tts_inference_job_token_queue.rs b/crates/service/websocket_gateway/src/endpoints_ws/threads/tts_inference_job_token_queue.rs index d829aa3878..a915e14823 100644 --- a/crates/service/websocket_gateway/src/endpoints_ws/threads/tts_inference_job_token_queue.rs +++ b/crates/service/websocket_gateway/src/endpoints_ws/threads/tts_inference_job_token_queue.rs @@ -30,7 +30,7 @@ impl TtsInferenceJobTokenQueue { } /// Pop a job token from the queue - pub fn dequeue_token(&self, job_token: &str) -> AnyhowResult> { + pub fn dequeue_token(&self) -> AnyhowResult> { match self.queue.lock() { Err(e) => { return Err(anyhow!("poisoned mutex: {:?}", e));