-
Notifications
You must be signed in to change notification settings - Fork 14
SubSocket: connection state hooks for publisher lifecycle events #209
Copy link
Copy link
Open
Description
Problem
The SubSocket driver manages publisher connection state internally (Active/Inactive transitions, backoff retries, reconnection). These transitions are invisible to consumers - there's no way to react when a publisher disconnects or reconnects.
Proposal
Add a connection state hook to SubSocket, similar to the existing ConnectionHook. This hook would fire on publisher state transitions in the driver.
pub trait SubConnectionStateHook<A>: Send + Sync + 'static {
fn on_connected(&self, addr: &A);
fn on_reconnected(&self, addr: &A);
fn on_disconnected(&self, addr: &A);
fn on_terminated(&self, addr: &A);
}let sub = SubSocket::new(transport)
.with_connection_hook(attest_hook)
.with_state_hook(my_state_hook);The driver already has the information to fire these - the transitions happen in poll_publishers (Active → Inactive) and on_connection (Inactive → Active). Distinguishing on_connected from on_reconnected requires tracking whether a publisher was previously Active.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels