You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move heartbeat/liveness logic into core behind the remote-adapter feature flag #767
Move the duplicated heartbeat/liveness logic from the postgres and mongodb
adapters into socketioxide_core behind the existing remote-adapter feature
flag, so it can be shared by each adapter.
Current state:
socketioxide-postgres and socketioxide-mongodb each define the same nodes_liveness: Mutex<Vec<(Uid, Instant)>> field, the same interval-based heartbeat_job, the same emit_heartbeat/emit_init_heartbeat helpers, the
same recv_heartbeat handler (~130 LOC duplicated verbatim, only the error
type differs) and the same server_count dead-node pruning.
The wire protocol already lives in core: RequestTypeOut/In::Heartbeat (20)
and InitHeartbeat (21) in crates/socketioxide-core/src/adapter/remote_packet.rs.
Redis is unaffected: it has no heartbeat (liveness is pub/sub subscriber
counting via num_serv).
Proposed shared API (sketch, in core behind remote-adapter):
HeartbeatTracker: wraps nodes_liveness + hb_timeout; on_heartbeat(origin)
(update-or-push, returns whether an InitHeartbeat reply is due), server_count()
(prune dead nodes + self), is_alive(uid).
HeartbeatSender trait: uid(), send_req(...), with default emit_heartbeat/emit_init_heartbeat implementations.
heartbeat_loop(interval, emit) helper and a default recv_heartbeat.
Postgres and mongodb then keep only a thin adapter: a HeartbeatTracker field
plus a small HeartbeatSender impl. No behavior or wire-format change.
Activity
refactor(core): move heartbeat/liveness logic into core behind remote…