PRO

Effect Read Replica Router

A read/write router for a primary with asynchronous replicas that keeps read-your-writes true: writes go to the primary and record the session's write LSN, and a read is only served from a replica whose applied LSN has caught up to that mark, otherwise it routes to the primary. Freshness is a comparison of two LSN Refs, not a timer guess, and any replica lagging beyond a configured ceiling is ejected for all sessions until it catches up, so a replica that silently falls minutes behind stops serving stale data to anyone. Solves the vanishing update after a save and unbounded staleness under replication lag. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-read-replica-router.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
routing
save v2
Effect<number>
profile served
v1
reload
unknown
db.replica.select(profile) // replication lag decides what you see

The user saves display_name=Ada, the write commits on the primary, and the reload reads from a replica that has not applied it yet. The page shows the OLD name. Watch the served value flash red: the write vanished from the user's point of view.

Files

Dependencies