Function get_stream

Source
pub async fn get_stream(
    self_endpoint: Endpoint,
    protocol: Protocol,
    remote_node_id52: String,
    peer_stream_senders: PeerStreamSenders,
) -> Result<(SendStream, FrameReader)>
Expand description

get_stream tries to check if the bidirectional stream is healthy, as simply opening a bidirectional stream, or even simply writing on it does not guarantee that the stream is open. only the read request times out to tell us something is wrong. this is why get_stream takes the protocol as well, as every outgoing bi-direction stream must have a protocol. it sends the protocol and waits for an ack. if the ack is not received within a certain time, it assumes the connection is not healthy, and tries to recreate the connection.

for managing connection, we use a spawned task. this task listens for incoming stream requests and manages the connection as part of the task local data.