pub async fn open_live_session<S>(
stream: S,
replica: Arc<Mutex<Replica>>,
workspace_id: GrainId,
) -> Result<(SessionOutcome, LiveSession)>Expand description
Run the initial exchange and then keep the session open.
Both sides call this: each sends what the other lacks during the exchange and afterwards
pushes what it commits, so the returned LiveSession is the same handle on either end
of the stream. The SessionOutcome is returned as soon as both sides have said Done
and Settled — “we are caught up” — while the session itself keeps going until a side
closes it or the stream ends.
The replica is locked per step — never while waiting for the peer’s Hello (issue #163)
or for content in flight: for each page and Want of the exchange, and then for each
arriving batch — so a scan or a local commit on this side waits behind one step rather
than behind the session. The exchange gives up on a peer that makes no progress for
IDLE_TIMEOUT; the live phase after it has no such bound.
Nothing is committed when the peer goes away or breaks the protocol: the error says which
happened, and the replica’s version vector is left where it was.
S must be 'static because both halves of the stream are moved into tasks; a stream
owned by the caller (a socket, a spliced pipe, a duplex) is.