proper productionize project

This commit is contained in:
2026-07-15 23:54:53 -07:00
parent b8850c87a4
commit edb6d2b5b4
46 changed files with 11346 additions and 1560 deletions
+23
View File
@@ -3,6 +3,7 @@
use native_tls::TlsStream;
use serde_json::Value;
use std::io::ErrorKind;
use std::net::TcpStream;
use std::panic;
use tungstenite::{client, Message, WebSocket};
@@ -134,6 +135,14 @@ impl BiliLiveClient {
}
Ok(())
}
Err(tungstenite::Error::Io(error))
if matches!(error.kind(), ErrorKind::WouldBlock | ErrorKind::TimedOut) =>
{
// A short read timeout lets an embedding application check
// its cancellation token without treating idle rooms as a
// disconnected WebSocket.
Ok(())
}
Err(e) => {
let msg = format!("read msg error: {}", e);
log::warn!("{}", msg);
@@ -147,6 +156,20 @@ impl BiliLiveClient {
}
}
/// Bound a blocking read so supervisors can stop/restart one tenant's
/// listener without leaking the previous connection.
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<(), String> {
self.ws
.get_mut()
.get_mut()
.set_read_timeout(timeout)
.map_err(|error| error.to_string())
}
pub fn close(&mut self) {
let _ = self.ws.close(None);
}
fn connect_with_auth(
cookies: &str,
room_id: &str,