Skip to main content

route_event

Function route_event 

Source
pub async fn route_event<T, M, R, Fut>(
    feed: FeedEvent<T>,
    wanted: bool,
    matches: M,
    readable: R,
) -> Result<Option<ModelEvent<T>>, CratestackError>
where M: Fn(&T) -> bool, R: Fn(&T) -> Fut, Fut: Future<Output = Result<bool, CratestackError>>,
Expand description

What one subscriber is sent for feed, if anything: the event itself when its row passes the subscriber’s filter and read policy (matches, readable, both on a row); otherwise, for an update, a filter-exit event (matches: false, §5.3) if the row before the write had passed both, so the subscriber’s copy is not left stale.

A filter-exit event’s data is the pre-image and never the post-image: the subscriber already holds that row (it passed the same checks, as a delete event’s row does), while the post-image may hold values it may not read, which is why the row left. A row that moved out of the read policy is therefore indistinguishable, to the subscriber, from one that left its filter. An update with no pre-image (a bulk update) yields no exit event.