Skip to main content

read_strongly_consistent_and_apply_effects

Function read_strongly_consistent_and_apply_effects 

Source
pub async fn read_strongly_consistent_and_apply_effects<T, F>(
    op: OperationVc<T>,
    get_effects: F,
) -> Result<ReadRef<T>>
where T: VcValueType, F: Fn(&<<T as VcValueType>::Read as VcRead<T>>::Target) -> &Effects,
Expand description

Strongly-consistent read of op, then apply its effects, retrying the whole read+apply on EffectsError::Retry.

get_effects extracts the Effects from the read value (for a wrapper struct this is |v| &v.effects; for an OperationVc<Effects> it is |e| e).

On EffectsError::Retry the producing operation has already been invalidated by Effects::apply, so the next read_strongly_consistent re-runs the producer and yields a fresh Effects whose capture() re-materializes content. Retries are bounded to avoid livelock when two producers perpetually stomp the same key; after the first retry a warning is logged on each subsequent attempt, and on exhaustion the last Retry surfaces as an error.

This is one of two public entry points for applying effects (see also resolve_strongly_consistent_and_take_and_apply_effects) — Effects::apply is private so the retry contract cannot be bypassed.