Skip to main content

read_state_rkey

Function read_state_rkey 

Source
pub fn read_state_rkey(feed_url: &str) -> String
Expand description

Derive the deterministic, stable rkey for a feed’s read-state record from its URL, so there is exactly one record per feed (a fixed key, not a fresh tid per flush).

atproto record keys must match [A-Za-z0-9._~:-]{1,512} (and not be ./..). A lowercase-hex FNV-1a-64 digest of the feed URL satisfies that, is stable across restarts and instances, and collides only on genuine hash collision (astronomically unlikely at feed scale; the flusher additionally dedups by rkey within a batch as a belt-and-braces guard).

The stable rkey is what makes create-then-update work: a feed’s FIRST flush emits an applyWrites#create at this key (tracked by read_cursor.pds_created) and every subsequent flush an #update at the same key, so there is exactly one record per feed and the first flush never fails on a missing record.