Skip to main content

caching_operation_update_stream

Function caching_operation_update_stream 

Source
pub fn caching_operation_update_stream<'a, U, S>(
    db: Database,
    operation_id: OperationId,
    stream: S,
    is_terminal: impl Fn(&U) -> bool + MaybeSend + 'a,
) -> BoxStream<'a, U>
where U: Clone + Serialize + Debug + MaybeSend + MaybeSync + 'static, S: Stream<Item = U> + MaybeSend + 'a,
Expand description

Wraps an operation update stream such that the last update before it closes is tried to be written to the operation log entry as its outcome — but only if is_terminal reports it as a final state of the operation. A stream that ends on a non-terminal update (e.g. an error-path early return in the stream generator) must not have that update cached as the outcome: OperationLog::outcome_or_updates short-circuits every later subscriber to the cached value, so caching a non-terminal update would freeze the operation’s observable state before its actual end.