Skip to main content

xread_block

Function xread_block 

Source
pub async fn xread_block(
    client: &Client,
    stream_key: &str,
    stream_meta_key: &str,
    last_id: &str,
    block_ms: u64,
    count_limit: u64,
) -> Result<StreamFrames, ScriptError>
Expand description

Tail frames from stream_key, blocking up to block_ms (0 = no block).

last_id is the exclusive cursor — XREAD returns entries with id > last_id. Pass "0-0" (or "0") to read from the beginning.

Returns a StreamFrames with frames=Vec::new() on timeout or when the stream has no new entries. The closed_at/closed_reason fields are populated from stream_meta on every call so consumers can stop polling when the producer finalizes the stream.

count_limit must be >= 1 and <= STREAM_READ_HARD_CAP. This mirrors crate::functions::stream::ff_read_attempt_stream and the REST/SDK boundaries; callers that silently clamped to 0 previously must now pass STREAM_READ_HARD_CAP explicitly.

§Timeout handling

For blocking calls (block_ms > 0), the ferriskey client automatically extends its request_timeout to block_ms + 500ms for the duration of this command. Callers do not need to (and should not) pass a custom client with a larger request_timeout just to accommodate tail. See the module-level docs for the exact ferriskey code path.