gorp: A small state-sync primitive for client/server replicas with optimistic updates.
const client = new GorpClient<{ count: number }, "inc">({
initialState: { count: 0 },
mutator: (state) => {
state.count += 1;
},
send: (cmd) => transport.send(cmd),
});
client.send("inc");
client.state.count; // 1 (optimistic)What gorp is
Gorp keeps a client-side replica of server state in sync over a caller-provided duplex transport. Commands flow up, deep-patch ops flow down, and the client renders an optimistic view that layers pending commands on top of the last server-confirmed state.
The primitives are small and orthogonal:
GorpClient— leaf replica + optimistic mutator + pending queue.GorpServer— authoritative state + command handler + op fan-out.GorpRelay— state mirror that pipes commands upstream and applies ops downstream. Useful when an edge node sits between client and origin.GorpSessions— wraps a server or relay with a sessioned wire protocol: per-session dedup, ack flushing, and resume-after-reconnect.