pub enum Resume {
Replay {
frames: Vec<SseEvent>,
last: EventId,
},
Live {
last: EventId,
},
Gap {
notice: SseEvent,
evicted_through: EventId,
resume_from: EventId,
last: EventId,
},
Refused(Refusal),
}Expand description
What to do with a stream a client has asked to resume.
Four arms, and the first three are all ways of keeping the stream open. The fourth is not: it means no stream is opened at all, and the client is answered with an error it can branch on. A caller that treated it as a fourth way of staying open would have invented a response the client never receives.
Variants§
Replay
Write these frames, then continue the live stream.
The frames are the complete answer: everything after the client’s
cursor is in here, and every one of them carries its own id: so the
client’s next reconnect has a cursor to quote.
Fields
Live
Write nothing, and hold the stream open.
Not a close, and not a keep-alive comment: a client must not be able to mistake an empty write for an event, and the comment form dispatches nothing so a client would learn of no error — but a client that asked to resume and is already current has lost nothing, so the honest answer is silence until something real happens.
Gap
Write notice, then continue the live stream.
The client is behind by more than the ring retains. It has lost events
and cannot get them back, and this is how it finds out. See the module
docs for why the notice carries no id:.
Fields
Refused(Refusal)
A refusal. Reuses Refusal so the status code and the JSON-RPC body
come from the one place that defines them.
Implementations§
Source§impl Resume
impl Resume
Sourcepub fn pending(&self) -> &[SseEvent]
pub fn pending(&self) -> &[SseEvent]
The frames to write before switching to the live stream.
The write loop’s whole job: write these, then go live. Empty for
Live and Refused, one frame for
Gap, and the whole window for Replay.
Note that a refusal is [] and the writer must not open the stream
for it, which is why this is not enough on its own to drive the
response — a caller matches on the arm to get the status.
Sourcepub const fn last(&self) -> Option<EventId>
pub const fn last(&self) -> Option<EventId>
The newest event id the stream has issued, when the decision has one.
None only for a refusal, which is not a stream at all. Useful for a
log line or a metric, both of which want the watermark whether the
client got a replay, an open stream, or a notice.