From 25b73e1054d83a6b512e790e3338b6b135d8537d Mon Sep 17 00:00:00 2001 From: zhenyi <434836402@qq.com> Date: Sat, 30 May 2026 15:07:07 +0800 Subject: [PATCH] refactor: update channel bus and thread event --- lib/channel/bus.rs | 30 +++++++++--------------------- lib/channel/event/thread.rs | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/lib/channel/bus.rs b/lib/channel/bus.rs index c412da9..4f65536 100644 --- a/lib/channel/bus.rs +++ b/lib/channel/bus.rs @@ -421,19 +421,15 @@ impl ChannelBus { async fn publish_event(&self, event: ChannelEvent) -> ChannelResult<()> { self.inner.metrics.increment_sent(); + // Best-effort broadcast — individual socket failures are expected + // (sockets disconnect) and should not block all broadcasts. let result = self .inner - .circuit_breaker - .call(async { - self.inner - .io - .namespace(&self.inner.config.namespace) - .await - .to(room_socket_name(event.room)) - .emit(ROOM_MESSAGE_EVENT, event) - .await - .map_err(ChannelError::SocketIo) - }) + .io + .namespace(&self.inner.config.namespace) + .await + .to(room_socket_name(event.room)) + .emit(ROOM_MESSAGE_EVENT, event) .await; match result { @@ -442,17 +438,9 @@ impl ChannelBus { Ok(()) } Err(e) => { + tracing::warn!(error = %e, "WS broadcast failed"); self.inner.metrics.increment_failed(); - match e { - crate::circuit_breaker::CircuitBreakerError::Open => { - Err(ChannelError::Internal( - "circuit breaker open".to_string(), - )) - } - crate::circuit_breaker::CircuitBreakerError::Inner(e) => { - Err(e) - } - } + Ok(()) // best-effort: don't propagate broadcast errors } } } diff --git a/lib/channel/event/thread.rs b/lib/channel/event/thread.rs index 3d373fc..da0ab63 100644 --- a/lib/channel/event/thread.rs +++ b/lib/channel/event/thread.rs @@ -103,3 +103,24 @@ pub struct ThreadArchiveClient { pub struct ThreadLoadClient { pub thread_id: Uuid, } + +/// A single thread item returned in the list endpoint +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ThreadListItem { + pub id: Uuid, + pub room: RoomInfo, + pub seq: i64, + pub parent_seq: i64, + pub title: String, + pub created_by: UserInfo, + pub archived: bool, + pub locked: bool, + pub last_message_at: Option>, + pub last_message_preview: Option, + pub created_at: DateTime, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ThreadListService { + pub threads: Vec, +}