Skip to content

Commit 9bda23d

Browse files
apollo_network: added sqmr GenericEvent docs (#8957)
* apollo_network: added network manager NetworkManager docs * apollo_network: added sqmr module docs * apollo_network: added sqmr OutboundSessionId docs * apollo_network: added sqmr InboundSessionId docs * apollo_network: added sqmr SessionId docs * apollo_network: added sqmr GenericEvent docs
1 parent e01d1e1 commit 9bda23d

File tree

1 file changed

+42
-0
lines changed
  • crates/apollo_network/src/sqmr

1 file changed

+42
-0
lines changed

crates/apollo_network/src/sqmr/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,66 @@ impl From<InboundSessionId> for SessionId {
132132
}
133133
}
134134

135+
/// Events emitted by the SQMR protocol during session lifecycle.
136+
///
137+
/// These events represent significant state changes in SQMR sessions that need
138+
/// to be handled by the network manager or application layer. The events cover
139+
/// the full lifecycle from session establishment to completion or failure.
140+
///
141+
/// # Type Parameters
142+
///
143+
/// * `SessionError` - The specific error type used for session failures
135144
#[derive(Debug)]
136145
pub enum GenericEvent<SessionError> {
146+
/// A new inbound session was established with a query from a peer.
147+
///
148+
/// This event is triggered when another peer sends a query to this node.
149+
/// The application should process the query and send appropriate responses
150+
/// using the provided session ID.
137151
NewInboundSession {
152+
/// The query bytes received from the peer.
138153
query: Bytes,
154+
/// Unique identifier for this inbound session.
139155
inbound_session_id: InboundSessionId,
156+
/// The peer ID that sent the query.
140157
peer_id: PeerId,
158+
/// The protocol identifier for this query.
141159
protocol_name: StreamProtocol,
142160
},
161+
162+
/// A response was received for an outbound session.
163+
///
164+
/// This event is triggered when a peer sends a response to a query that
165+
/// this node initiated. Multiple such events may be received for a single
166+
/// outbound session in the SQMR pattern.
143167
ReceivedResponse {
168+
/// Unique identifier of the outbound session that received this response.
144169
outbound_session_id: OutboundSessionId,
170+
/// The response bytes received from the peer.
145171
response: Bytes,
172+
/// The peer ID that sent the response.
146173
peer_id: PeerId,
147174
},
175+
176+
/// A session failed due to an error.
177+
///
178+
/// This event indicates that a session (either inbound or outbound) has
179+
/// failed and will not produce any more events. The session should be
180+
/// considered closed and any associated resources cleaned up.
148181
SessionFailed {
182+
/// The ID of the session that failed.
149183
session_id: SessionId,
184+
/// The specific error that caused the session to fail.
150185
error: SessionError,
151186
},
187+
188+
/// A session completed successfully.
189+
///
190+
/// This event indicates that a session has finished normally without errors.
191+
/// For outbound sessions, this means the peer has finished sending responses.
192+
/// For inbound sessions, this means all responses have been sent successfully.
152193
SessionFinishedSuccessfully {
194+
/// The ID of the session that completed.
153195
session_id: SessionId,
154196
},
155197
}

0 commit comments

Comments
 (0)