Function serve_sync
pub async fn serve_sync<S, I>(
peer: &StoreSyncPeer<S, I>,
route: Route,
request: &[u8],
) -> Result<Vec<u8>, ServeError<S::Error, I::Error>>where
S: WriteGroupStore,
I: IngestStore,Expand description
Answers one request through peer, and returns the reply’s bytes.
request is the body exactly as it arrived: a postcard
Envelope holding a
PullRequest on Route::Pull or a PushBatch on Route::Push.
The reply is an envelope holding a Pulled<ResumeToken> or an
Ack. Which message a buffer holds is the transport’s to say
(ADR-0097); a body sent on the wrong route can be refused as malformed, or
can decode as the other message, and only the transport can prevent that.
The token a pull answers with is StoreResume’s text form, so the client
hands back what this minted and nothing else is ever asked to read it.
§What the transport owns
The size of request. It is untrusted and fully buffered by the time it
arrives here, so the cap belongs where it is read: a transport refuses a
body much larger than the peer’s
max_batch_bytes before calling this.
Turning an error into a reply. There is no error message in the wire
set, so a transport maps ServeError::class to whatever
its client can classify again — for HTTP, say, Transient to 503, Split
to 413, Park to 422 and Stop to 400 — and the client’s
Exchange error reports that class back.
§Errors
ServeError::Codecif the request is not an envelope this build reads: another format version, or malformed bytes.ServeError::Tokenif a pull resumes from a token no store peer minted.ServeError::Peerif the peer refuses or fails, asStoreSyncPeer’s pull and push document.