Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn open_default() -> Result<Store>

Source

pub fn open(path: &Path) -> Result<Store>

Source

pub fn config_rows(&self) -> Result<Vec<(String, String)>>

Source

pub fn set_config(&self, key: &str, value: &str) -> Result<()>

Source

pub fn reset_config(&self, key: &str) -> Result<bool>

Returns whether a stored value was removed.

Source

pub fn roots(&self) -> Result<Vec<PathBuf>>

Source

pub fn add_root(&self, path: &Path) -> Result<bool>

Returns false when the root was already present.

Source

pub fn remove_root(&self, path: &Path) -> Result<bool>

Source

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.

Source

pub fn last_scan(&self) -> Result<Option<i64>>

Source

pub fn project(&self, name: &str) -> Result<Option<ProjectRow>>

Source

pub fn projects(&self) -> Result<Vec<ProjectRow>>

Source

pub fn tasks(&self) -> Result<Vec<TaskRow>>

Source

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.

Source

pub fn project_footprint(&self, name: &str) -> Result<Footprint>

What forgetting a project would delete, and what would hold it back.

Source

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.

Source

pub fn project_tags(&self) -> Result<Vec<(String, String)>>

Every (project, tag) pair, ordered by project then tag.

Source

pub fn add_project_tag(&self, project: &str, tag: &str) -> Result<bool>

Returns false when the project already had the tag.

Source

pub fn remove_project_tag(&self, project: &str, tag: &str) -> Result<bool>

Returns false when the project did not have the tag.

Source

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.

Source

pub fn notes(&self) -> Result<Vec<Note>>

Source

pub fn add_job(&self, args: &[String], cwd: &Path) -> Result<i64>

Source

pub fn jobs(&self, limit: i64) -> Result<Vec<Job>>

The newest limit jobs, newest first.

Source

pub fn job(&self, id: i64) -> Result<Job>

Source

pub fn claim_job(&self) -> Result<Option<Job>>

Marks the oldest queued job running and returns it.

Source

pub fn set_job_awaiting(&self, id: i64, args: &[String]) -> Result<()>

Records what would approve the plan a job stopped at.

Source

pub fn approve_job(&self, id: i64) -> Result<bool>

Marks an awaiting job approved. False if it was not awaiting.

Source

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.

Source

pub fn set_job_pid(&self, id: i64, pid: u32) -> Result<()>

Source

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.

Source

pub fn stop_job(&self, id: i64) -> Result<String>

Returns the state the job was in. Only a queued or running job stops.

Source

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.

Source

pub fn has_queued_jobs(&self) -> Result<bool>

Source

pub fn add_note(&self, text: &str, now: i64) -> Result<i64>

Source

pub fn edit_note(&self, id: i64, text: &str, now: i64) -> Result<bool>

Returns false when no note has the id.

Source

pub fn remove_note(&self, id: i64) -> Result<bool>

Returns false when no note has the id.

Source

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.

Source

pub fn update_run(&self, run: &Run) -> Result<()>

Writes every mutable column of the run with run.id.

Source

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.

Source

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.

Source

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.

Source

pub fn runs(&self) -> Result<Vec<Run>>

Source

pub fn run(&self, id: i64) -> Result<Run>

Source

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.

Source

pub fn campaigns(&self) -> Result<Vec<Campaign>>

Source

pub fn campaign(&self, name: &str) -> Result<Campaign>

Source

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.

Source

pub fn remove_campaign(&self, name: &str) -> Result<bool>

Returns false when no campaign has the name.

Source

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.

Source

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.

Source

pub fn route_revisions(&self) -> Result<Vec<RouteRevision>>

Every revision, oldest first.

Source

pub fn active_route(&self) -> Result<Option<RouteRevision>>

The revision in effect, if any.

Source

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.

Source

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.

Source

pub fn workflow_revisions(&self) -> Result<Vec<WorkflowRevision>>

Every revision, oldest first.

Source

pub fn active_workflow(&self) -> Result<Option<WorkflowRevision>>

The revision in effect, if any.

Source

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.

Source

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.

Source

pub fn workflow_instances(&self) -> Result<Vec<WorkflowInstance>>

Source

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.

Source

pub fn workflow_instance( &self, instance: i64, ) -> Result<Option<WorkflowInstance>>

One instance by id.

Source

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.

Source

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.

Source

pub fn finish_instance(&self, instance: i64, outcome: &str) -> Result<()>

Source

pub fn add_workflow_unit(&self, instance: i64, u: &WorkflowUnit) -> Result<()>

Units are immutable, so this only ever inserts.

Source

pub fn workflow_units(&self, instance: i64) -> Result<Vec<WorkflowUnit>>

Source

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.

Source

pub fn workflow_moves( &self, instance: i64, ) -> Result<Vec<(String, usize, bool)>>

Every move recorded, as (unit, edge, taken).

Source

pub fn add_workflow_verdict( &self, instance: i64, unit: &str, check: &str, verdict: &str, detail: Option<&str>, ) -> Result<()>

Source

pub fn workflow_verdicts( &self, instance: i64, ) -> Result<Vec<(String, String, String)>>

Verdicts by unit and check name.

Source

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.

Source

pub fn presets(&self) -> Result<Vec<Preset>>

Source

pub fn preset(&self, name: &str) -> Result<Preset>

Source

pub fn remove_preset(&self, name: &str) -> Result<bool>

Returns false when no preset has the name.

Source

pub fn agents(&self) -> Result<Vec<Worker>>

Every worker, by name.

Source

pub fn agent(&self, name: &str) -> Result<Worker>

Source

pub fn set_agent(&self, w: &Worker) -> Result<()>

Source

pub fn remove_agent(&self, name: &str) -> Result<bool>

Returns false when no agent has the name.

Source

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.

Source

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.

Source

pub fn consumed_attempts(&self, project: &str, revision: &str) -> Result<i64>

Attempts consumed against a task revision, across every run of it.

Source

pub fn consume_attempt(&self, project: &str, revision: &str) -> Result<i64>

Records one consumed attempt and returns the new total.

Source

pub fn refund_attempts( &self, project: &str, revision: &str, n: i64, ) -> Result<()>

Takes back n consumed attempts, never below none.

Source

pub fn reset_attempts(&self, project: &str, revision: &str) -> Result<bool>

Returns false when the revision had consumed none.

Source

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.

Source

pub fn set_verify_base( &self, project: &str, base: &str, command: &str, timeout_minutes: i64, sandbox: bool, ok: Option<bool>, seconds: i64, ) -> Result<()>

Source

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.

Source

pub fn attempts(&self, run: Option<i64>) -> Result<Vec<Attempt>>

Every attempt, oldest first. run limits it to one run.

Source

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.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.