pub struct Mirror { /* private fields */ }Implementations§
Source§impl Mirror
impl Mirror
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
The mirror in one file, created if it does not exist.
A file written by another version of this schema is refused: reading one optimistically is how a page comes to render half a board.
pub fn path(&self) -> &Path
pub fn state(&self, scope: &Scope) -> Result<SyncState>
Sourcepub fn states(&self) -> Result<BTreeMap<String, SyncState>>
pub fn states(&self) -> Result<BTreeMap<String, SyncState>>
Every scope this mirror knows about.
Sourcepub fn synced(
&self,
scope: &Scope,
etag: Option<&str>,
cursor: Option<&str>,
) -> Result<()>
pub fn synced( &self, scope: &Scope, etag: Option<&str>, cursor: Option<&str>, ) -> Result<()>
Record a sync that worked.
Clears last_error: the scope is current, and a stale error beside
current data is a page reporting a problem that is over.
Sourcepub fn failed(&self, scope: &Scope, error: &str) -> Result<()>
pub fn failed(&self, scope: &Scope, error: &str) -> Result<()>
Record an attempt that failed.
Leaves synced_at, the ETag and the cursor alone: the data this scope
holds is still the data GitHub last gave it, and the next attempt
should still be conditional.
Sourcepub fn hold(&self, scope: &Scope) -> Result<()>
pub fn hold(&self, scope: &Scope) -> Result<()>
Put a scope in the sweep before it has ever been read.
What opening a comment thread does: a thread nobody has opened is not worth a request per sweep, and one somebody opened is. Recorded as a scope with no data and no attempt, which is exactly “not read yet”.
Sourcepub fn forget_repository(&self, repo: &str) -> Result<usize>
pub fn forget_repository(&self, repo: &str) -> Result<usize>
Forget everything about one repository.
For a repository no project has any more: its issues, its pull requests, its releases and everything else go together, and a list of kinds to delete would be a list to keep in step with every kind added afterwards.
Sourcepub fn put(&self, scope: &Scope, documents: &[Document]) -> Result<bool>
pub fn put(&self, scope: &Scope, documents: &[Document]) -> Result<bool>
Write what a fetch returned, and say whether anything changed.
An AUTHORITATIVE scope replaces its contents: what the answer does not mention no longer exists. An incremental one only adds and updates, because its answer is “what changed”, and clearing on that empties the mirror every time nothing did.
Sourcepub fn put_one(&self, scope: &Scope, document: Document) -> Result<bool>
pub fn put_one(&self, scope: &Scope, document: Document) -> Result<bool>
Write one document — what a create or an edit produced.
Never prunes, whatever the scope: one document is not an answer about what exists.
Sourcepub fn remove_one(&self, scope: &Scope, key: &str) -> Result<bool>
pub fn remove_one(&self, scope: &Scope, key: &str) -> Result<bool>
Take one document out of a scope — what a deletion on GitHub produced.
Sourcepub fn put_project_write(
&self,
boards_scope: &Scope,
board: Document,
items_scope: &Scope,
items: &[Document],
) -> Result<()>
pub fn put_project_write( &self, boards_scope: &Scope, board: Document, items_scope: &Scope, items: &[Document], ) -> Result<()>
Atomically store one changed board and the complete card set GitHub returned after that board changed.
A removed column changes both documents at once: the board loses an option and its cards lose that option’s values. Committing those in two transactions creates a state no GitHub answer ever had if the second write fails, so this is one database act.
Sourcepub fn documents(&self, scope: &Scope) -> Result<Vec<Document>>
pub fn documents(&self, scope: &Scope) -> Result<Vec<Document>>
Everything one scope holds, newest movement first.
Sourcepub fn payloads(&self, scope: &Scope) -> Result<Vec<Value>>
pub fn payloads(&self, scope: &Scope) -> Result<Vec<Value>>
Just the payloads, which is what a reader serves.
Sourcepub fn document(&self, scope: &Scope, key: &str) -> Result<Option<Document>>
pub fn document(&self, scope: &Scope, key: &str) -> Result<Option<Document>>
One document, when the scope holds it.
Sourcepub fn only(&self, scope: &Scope) -> Result<Option<Value>>
pub fn only(&self, scope: &Scope) -> Result<Option<Value>>
The single document of a scope that holds exactly one: a repository’s metadata, a commit’s checks, its traffic, the rate limit.
Sourcepub fn put_only(&self, scope: &Scope, payload: Value) -> Result<bool>
pub fn put_only(&self, scope: &Scope, payload: Value) -> Result<bool>
Write the single document of such a scope.
Sourcepub fn counts_by_state(&self, scope: &Scope) -> Result<BTreeMap<String, i64>>
pub fn counts_by_state(&self, scope: &Scope) -> Result<BTreeMap<String, i64>>
How many documents of each state one scope holds.
Counted in SQL: an explorer asks this for every row it draws, and reading every payload to answer would make a redraw proportional to the whole mirror.
Sourcepub fn open_counts(&self, kind: &str) -> Result<BTreeMap<String, i64>>
pub fn open_counts(&self, kind: &str) -> Result<BTreeMap<String, i64>>
How many documents are open, per repository, across every scope of one
kind (issues or pulls).
One query for a whole tree rather than one per row.
Sourcepub fn latest_change(&self) -> Result<i64>
pub fn latest_change(&self) -> Result<i64>
The newest change recorded, or 0 when nothing ever changed.
Sourcepub fn changes_since(&self, since: i64) -> Result<Changes>
pub fn changes_since(&self, since: i64) -> Result<Changes>
Which scopes changed after change since, written by whichever process.