Skip to main content

Module mirror

Module mirror 

Source
Expand description

The machine’s copy of what GitHub said.

§Why a mirror rather than a cache

Every list used to be fetched from the API when a page opened. That made the page as fast as the network, as available as the credential, and as honest as the last request — and when a request failed, the list rendered EMPTY. A missing token, a rate limit or a closed laptop each produced “you have no gists”, which is a lie told confidently.

So a copy is kept and every reader reads the copy. Reads never touch the network, never need a token, and never fail because GitHub is having a morning. What a read CAN say is how old its answer is and whether the last refresh failed, which is the honest version of the same page.

§One per machine

GitHub’s repositories, gists, notifications and project boards belong to accounts, not to any checkout, and one board spans many repositories. So there is one mirror for every project under $PRJ, in $PRJ/.state, and every process that reads or writes GitHub through this crate shares it.

§What is stored

Whole payloads, as GitHub sent them. The columns beside them exist only to be queried on — state, update time — and everything a reader renders comes out of the payload.

Structs§

Document
One document, as GitHub last described it.
Mirror
Standing
How current one scope’s answer is, as every reader is told it.
SyncState
Where one scope stands: how current it is, and what went wrong last.

Enums§

Changes
What changed since a reader last looked.
Scope
What one mirrored thing is called, and what a sync is about.

Constants§

FILE
The file the mirror lives in, under $PRJ/.state.
SINGLETON
The key a scope that holds exactly one document stores it under.

Functions§

gist_is_whole
Whether a gist payload carries file contents rather than just their names.
newest_update
The newest updated_at in a set, which becomes the next fetch’s since.