pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
pub fn open_default() -> Result<Store>
pub fn open(path: &Path) -> Result<Store>
pub fn config_rows(&self) -> Result<Vec<(String, String)>>
pub fn set_config(&self, key: &str, value: &str) -> Result<()>
Sourcepub fn reset_config(&self, key: &str) -> Result<bool>
pub fn reset_config(&self, key: &str) -> Result<bool>
Returns whether a stored value was removed.
pub fn roots(&self) -> Result<Vec<PathBuf>>
Sourcepub fn add_root(&self, path: &Path) -> Result<bool>
pub fn add_root(&self, path: &Path) -> Result<bool>
Returns false when the root was already present.
pub fn remove_root(&self, path: &Path) -> Result<bool>
Sourcepub fn set_tier(&self, name: &str, path: &Path, tier: Option<u8>) -> Result<()>
pub fn set_tier(&self, name: &str, path: &Path, tier: Option<u8>) -> Result<()>
Records the project first if no scan has, so the tier has a row.
pub fn last_scan(&self) -> Result<Option<i64>>
pub fn project(&self, name: &str) -> Result<Option<ProjectRow>>
pub fn projects(&self) -> Result<Vec<ProjectRow>>
pub fn tasks(&self) -> Result<Vec<TaskRow>>
Sourcepub fn save_scan(
&mut self,
facts: &[Facts],
full: bool,
now: i64,
) -> Result<Vec<String>>
pub fn save_scan( &mut self, facts: &[Facts], full: bool, now: i64, ) -> Result<Vec<String>>
Records scan results. Each task keeps the first_seen it had in the
previous scan. With full, projects not in facts are deleted and
returned with the tier they had.
Records the scan. A full scan marks every project it did not find as
absent and returns their names; the rows stay, since a project that
leaves a root is usually a move, not a deletion.
Sourcepub fn project_footprint(&self, name: &str) -> Result<Footprint>
pub fn project_footprint(&self, name: &str) -> Result<Footprint>
What forgetting a project would delete, and what would hold it back.
Sourcepub fn forget_project(&mut self, name: &str) -> Result<()>
pub fn forget_project(&mut self, name: &str) -> Result<()>
Deletes a project’s record and everything keyed to it but its runs, whose worktrees may still exist and which the design keeps beyond a project’s removal. Caller checks that nothing holds it back.
Every (project, tag) pair, ordered by project then tag.
Sourcepub fn add_project_tag(&self, project: &str, tag: &str) -> Result<bool>
pub fn add_project_tag(&self, project: &str, tag: &str) -> Result<bool>
Returns false when the project already had the tag.
Sourcepub fn remove_project_tag(&self, project: &str, tag: &str) -> Result<bool>
pub fn remove_project_tag(&self, project: &str, tag: &str) -> Result<bool>
Returns false when the project did not have the tag.
Sourcepub fn projects_tagged(&self, tags: &[String]) -> Result<Vec<String>>
pub fn projects_tagged(&self, tags: &[String]) -> Result<Vec<String>>
The projects carrying any of tags, in name order. A project in
several of them appears once.
pub fn notes(&self) -> Result<Vec<Note>>
pub fn add_job(&self, args: &[String], cwd: &Path) -> Result<i64>
pub fn job(&self, id: i64) -> Result<Job>
Sourcepub fn claim_job(&self) -> Result<Option<Job>>
pub fn claim_job(&self) -> Result<Option<Job>>
Marks the oldest queued job running and returns it.
Sourcepub fn set_job_awaiting(&self, id: i64, args: &[String]) -> Result<()>
pub fn set_job_awaiting(&self, id: i64, args: &[String]) -> Result<()>
Records what would approve the plan a job stopped at.
Sourcepub fn approve_job(&self, id: i64) -> Result<bool>
pub fn approve_job(&self, id: i64) -> Result<bool>
Marks an awaiting job approved. False if it was not awaiting.
Sourcepub fn settle_jobs_awaiting(&self, plan: &str) -> Result<()>
pub fn settle_jobs_awaiting(&self, plan: &str) -> Result<()>
Marks every job awaiting plan approved, once that plan has run by
any route. Plan ids are hex, so the quoted match is exact.
pub fn set_job_pid(&self, id: i64, pid: u32) -> Result<()>
Sourcepub fn finish_job(&self, id: i64, exit_code: Option<i32>) -> Result<()>
pub fn finish_job(&self, id: i64, exit_code: Option<i32>) -> Result<()>
Records how a job ended. A job stopped while it ran stays stopped.
Sourcepub fn stop_job(&self, id: i64) -> Result<String>
pub fn stop_job(&self, id: i64) -> Result<String>
Returns the state the job was in. Only a queued or running job stops.
Sourcepub fn fail_running_jobs(&self) -> Result<usize>
pub fn fail_running_jobs(&self) -> Result<usize>
Jobs left running by a runner that exited. Called under the runner
lock, so no live runner holds them.
pub fn has_queued_jobs(&self) -> Result<bool>
pub fn add_note(&self, text: &str, now: i64) -> Result<i64>
Sourcepub fn edit_note(&self, id: i64, text: &str, now: i64) -> Result<bool>
pub fn edit_note(&self, id: i64, text: &str, now: i64) -> Result<bool>
Returns false when no note has the id.
Sourcepub fn remove_note(&self, id: i64) -> Result<bool>
pub fn remove_note(&self, id: i64) -> Result<bool>
Returns false when no note has the id.
Sourcepub fn insert_run(&self, run: &mut Run) -> Result<i64>
pub fn insert_run(&self, run: &mut Run) -> Result<i64>
Assigns the run’s id and stamps dispatched_at, in the row and in
run.
Sourcepub fn update_run(&self, run: &Run) -> Result<()>
pub fn update_run(&self, run: &Run) -> Result<()>
Writes every mutable column of the run with run.id.
Sourcepub fn update_run_from(&self, run: &Run, read: RunState) -> Result<()>
pub fn update_run_from(&self, run: &Run, read: RunState) -> Result<()>
update_run, only while the row is still in read, the state the copy
was read in. For a command that holds no session lock, so its stale
copy cannot undo a publish that ran meanwhile.
Sourcepub fn add_review_seconds(&self, id: i64, seconds: i64) -> Result<()>
pub fn add_review_seconds(&self, id: i64, seconds: i64) -> Result<()>
Adds review time in one column, so a command that holds no session lock writes nothing else.
Sourcepub fn set_reviewed_tree(&self, id: i64, tree: &str) -> Result<()>
pub fn set_reviewed_tree(&self, id: i64, tree: &str) -> Result<()>
Records the tree pma review <id> showed. One column, so a reading
command does not write back a copy of the whole run.
pub fn runs(&self) -> Result<Vec<Run>>
pub fn run(&self, id: i64) -> Result<Run>
Sourcepub fn add_campaign(&self, c: &Campaign) -> Result<()>
pub fn add_campaign(&self, c: &Campaign) -> Result<()>
Creates a campaign with a fixed membership. The set does not change afterwards: a rescan must not move work under a campaign in flight.
pub fn campaigns(&self) -> Result<Vec<Campaign>>
pub fn campaign(&self, name: &str) -> Result<Campaign>
Sourcepub fn set_campaign_run(
&self,
campaign: &str,
project: &str,
run: i64,
) -> Result<()>
pub fn set_campaign_run( &self, campaign: &str, project: &str, run: i64, ) -> Result<()>
Records which run took a member, so a restart does not dispatch it again and open a second pull request.
Sourcepub fn remove_campaign(&self, name: &str) -> Result<bool>
pub fn remove_campaign(&self, name: &str) -> Result<bool>
Returns false when no campaign has the name.
Sourcepub fn add_route_revision(&self, document: &str, by: &str) -> Result<i64>
pub fn add_route_revision(&self, document: &str, by: &str) -> Result<i64>
Stores a policy revision as a draft and returns its number. Storing is not activating: nothing routes by it until someone says so.
Sourcepub fn activate_route(
&self,
revision: i64,
by: &str,
shadow: bool,
) -> Result<()>
pub fn activate_route( &self, revision: i64, by: &str, shadow: bool, ) -> Result<()>
Puts a revision into effect, in shadow or for real, and retires any
other. by is recorded: raising autonomy is somebody’s decision.
Sourcepub fn route_revisions(&self) -> Result<Vec<RouteRevision>>
pub fn route_revisions(&self) -> Result<Vec<RouteRevision>>
Every revision, oldest first.
Sourcepub fn active_route(&self) -> Result<Option<RouteRevision>>
pub fn active_route(&self) -> Result<Option<RouteRevision>>
The revision in effect, if any.
Sourcepub fn add_workflow_revision(
&self,
doc: &Document,
source: Option<&str>,
by: &str,
worst_case_runs: i64,
worst_case_cost: f64,
) -> Result<i64>
pub fn add_workflow_revision( &self, doc: &Document, source: Option<&str>, by: &str, worst_case_runs: i64, worst_case_cost: f64, ) -> Result<i64>
Stores a document as a draft. Refused here, so an unreadable one never
reaches the table, and stored normalised, so two revisions diff by what
they mean rather than by how they were typed – or by whether a script
or a person wrote them. source keeps the script for provenance.
Sourcepub fn activate_workflow(&self, revision: i64, by: &str) -> Result<()>
pub fn activate_workflow(&self, revision: i64, by: &str) -> Result<()>
Puts a revision into effect and retires any other. by is recorded:
what a workflow may spend is somebody’s decision.
Sourcepub fn workflow_revisions(&self) -> Result<Vec<WorkflowRevision>>
pub fn workflow_revisions(&self) -> Result<Vec<WorkflowRevision>>
Every revision, oldest first.
Sourcepub fn active_workflow(&self) -> Result<Option<WorkflowRevision>>
pub fn active_workflow(&self) -> Result<Option<WorkflowRevision>>
The revision in effect, if any.
Sourcepub fn workflow_revision(
&self,
revision: i64,
) -> Result<Option<WorkflowRevision>>
pub fn workflow_revision( &self, revision: i64, ) -> Result<Option<WorkflowRevision>>
One revision by number. What an instance resumes under, which is the revision it recorded rather than whichever is in effect now.
Sourcepub fn add_workflow_instance(
&self,
workflow: &str,
revision: i64,
args: &str,
target: &str,
) -> Result<i64>
pub fn add_workflow_instance( &self, workflow: &str, revision: i64, args: &str, target: &str, ) -> Result<i64>
Starts an instance: the frozen argument bag and what it was run over.
pub fn workflow_instances(&self) -> Result<Vec<WorkflowInstance>>
Sourcepub fn atomically<T>(&self, work: impl FnOnce() -> Result<T>) -> Result<T>
pub fn atomically<T>(&self, work: impl FnOnce() -> Result<T>) -> Result<T>
Runs work in one transaction, committing only where it succeeds.
A workflow node writes several rows per unit – the units it produced, the moves that route them, the marker saying it is done with its input – and a failure part way through would leave a unit routed by a node that had not finished with it. The boundary is one unit, not one node: a sink writes a file, and a unit whose file is written and whose move is not would have its sink run twice.
Sourcepub fn workflow_instance(
&self,
instance: i64,
) -> Result<Option<WorkflowInstance>>
pub fn workflow_instance( &self, instance: i64, ) -> Result<Option<WorkflowInstance>>
One instance by id.
Sourcepub fn note_instance_outcome(&self, instance: i64, outcome: &str) -> Result<()>
pub fn note_instance_outcome(&self, instance: i64, outcome: &str) -> Result<()>
Records why an instance cannot go on, without closing it. A pass that hit a cap has work recorded and a reason it stopped, and neither is a finished workflow.
Sourcepub fn reopen_instance(&self, instance: i64, args: &str) -> Result<()>
pub fn reopen_instance(&self, instance: i64, args: &str) -> Result<()>
Records new arguments on an instance and clears the outcome that stopped it, so a raised cap resumes it.
pub fn finish_instance(&self, instance: i64, outcome: &str) -> Result<()>
Sourcepub fn add_workflow_unit(&self, instance: i64, u: &WorkflowUnit) -> Result<()>
pub fn add_workflow_unit(&self, instance: i64, u: &WorkflowUnit) -> Result<()>
Units are immutable, so this only ever inserts.
pub fn workflow_units(&self, instance: i64) -> Result<Vec<WorkflowUnit>>
Sourcepub fn add_workflow_move(
&self,
instance: i64,
unit: &str,
edge: usize,
taken: bool,
reason: Option<&str>,
) -> Result<()>
pub fn add_workflow_move( &self, instance: i64, unit: &str, edge: usize, taken: bool, reason: Option<&str>, ) -> Result<()>
One row per unit and edge: which way it went, or the guard that refused it. A unit that stopped is therefore answerable for.
Sourcepub fn workflow_moves(
&self,
instance: i64,
) -> Result<Vec<(String, usize, bool)>>
pub fn workflow_moves( &self, instance: i64, ) -> Result<Vec<(String, usize, bool)>>
Every move recorded, as (unit, edge, taken).
pub fn add_workflow_verdict( &self, instance: i64, unit: &str, check: &str, verdict: &str, detail: Option<&str>, ) -> Result<()>
Sourcepub fn workflow_verdicts(
&self,
instance: i64,
) -> Result<Vec<(String, String, String)>>
pub fn workflow_verdicts( &self, instance: i64, ) -> Result<Vec<(String, String, String)>>
Verdicts by unit and check name.
Sourcepub fn set_preset(&self, p: &Preset) -> Result<()>
pub fn set_preset(&self, p: &Preset) -> Result<()>
Names a worker, a model and the arguments that configure it. Replaces one of the same name.
pub fn presets(&self) -> Result<Vec<Preset>>
pub fn preset(&self, name: &str) -> Result<Preset>
Sourcepub fn remove_preset(&self, name: &str) -> Result<bool>
pub fn remove_preset(&self, name: &str) -> Result<bool>
Returns false when no preset has the name.
pub fn agent(&self, name: &str) -> Result<Worker>
pub fn set_agent(&self, w: &Worker) -> Result<()>
Sourcepub fn remove_agent(&self, name: &str) -> Result<bool>
pub fn remove_agent(&self, name: &str) -> Result<bool>
Returns false when no agent has the name.
Sourcepub fn decided_runs(&self, project: &str) -> Result<(i64, i64)>
pub fn decided_runs(&self, project: &str) -> Result<(i64, i64)>
Decided runs in a project and how many were accepted. An open pull request is in neither: no one has judged it.
Sourcepub fn rekey_runs(
&self,
project: &str,
old: &str,
text: &str,
new: &str,
) -> Result<()>
pub fn rekey_runs( &self, project: &str, old: &str, text: &str, new: &str, ) -> Result<()>
Moves the runs still holding a task onto its new key, once pma has
written an id into its line: those keyed by its old key or by its text.
A finished run keeps the key it was dispatched under.
Sourcepub fn consumed_attempts(&self, project: &str, revision: &str) -> Result<i64>
pub fn consumed_attempts(&self, project: &str, revision: &str) -> Result<i64>
Attempts consumed against a task revision, across every run of it.
Sourcepub fn consume_attempt(&self, project: &str, revision: &str) -> Result<i64>
pub fn consume_attempt(&self, project: &str, revision: &str) -> Result<i64>
Records one consumed attempt and returns the new total.
Sourcepub fn refund_attempts(
&self,
project: &str,
revision: &str,
n: i64,
) -> Result<()>
pub fn refund_attempts( &self, project: &str, revision: &str, n: i64, ) -> Result<()>
Takes back n consumed attempts, never below none.
Sourcepub fn reset_attempts(&self, project: &str, revision: &str) -> Result<bool>
pub fn reset_attempts(&self, project: &str, revision: &str) -> Result<bool>
Returns false when the revision had consumed none.
Sourcepub fn verify_base(
&self,
project: &str,
base: &str,
command: &str,
timeout_minutes: i64,
sandbox: bool,
) -> Result<Option<(Option<bool>, i64)>>
pub fn verify_base( &self, project: &str, base: &str, command: &str, timeout_minutes: i64, sandbox: bool, ) -> Result<Option<(Option<bool>, i64)>>
A base verification of this exact repository, commit, command,
timeout and sandbox, or None when it has not been measured.
pub fn set_verify_base( &self, project: &str, base: &str, command: &str, timeout_minutes: i64, sandbox: bool, ok: Option<bool>, seconds: i64, ) -> Result<()>
Sourcepub fn insert_attempt(&self, a: &Attempt) -> Result<i64>
pub fn insert_attempt(&self, a: &Attempt) -> Result<i64>
Appends an attempt. n is assigned here, so two reworks cannot race
to the same number.
Sourcepub fn attempts(&self, run: Option<i64>) -> Result<Vec<Attempt>>
pub fn attempts(&self, run: Option<i64>) -> Result<Vec<Attempt>>
Every attempt, oldest first. run limits it to one run.
Sourcepub fn fail_interrupted_runs(&self, _held: &Session) -> Result<usize>
pub fn fail_interrupted_runs(&self, _held: &Session) -> Result<usize>
Marks runs left queued or running by a session that ended as failed.
Only a Session holder runs agents, so while it is held none is live.