Skip to main content

Tx

Struct Tx 

Source
pub struct Tx<'c> { /* private fields */ }
Expand description

A transaction over the store: every query and change is one of its methods; the changes need &mut, so they are made only in Store::write.

Implementations§

Source§

impl Tx<'_>

Source

pub fn record_download( &mut self, run: Option<&RunName>, item: &DownloadItem, ) -> Result<bool>

Records that run run’s tool fetched item (no run: adopted); one recorded already keeps its row. Whether it was new to the record.

§Errors

The store can’t be written.

Source

pub fn downloads(&self) -> Result<Vec<Download>>

Every recorded download, oldest first (its size unread).

§Errors

The store can’t be read, or a row holds what this runner doesn’t write.

Source

pub fn forget_download(&mut self, id: DownloadId) -> Result<()>

Forgets download id (removed, or found gone); one not recorded is fine.

§Errors

The store can’t be written.

Source§

impl Tx<'_>

Source

pub fn queue_operation( &mut self, run: &RunName, op: Op, owner: &Owner, ) -> Result<OperationRow>

Journals operation op on run as queued by owner (a service answering a command): its id is the one every later event and the client see; Tx::start_operation starts it.

§Errors

The store can’t be written.

Source

pub fn start_operation( &mut self, id: OperationId, run: &RunName, owner: &Owner, resumed_from: Option<OperationId>, ) -> Result<OperationRow>

Starts queued operation id of run, owned now by owner, recovering resumed_from when it found that one unfinished.

§Errors

illegal_transition when id isn’t a queued operation of run (started or ended already, another run’s, or none); the store’s.

Source

pub fn begin_operation( &mut self, run: &RunName, op: Op, owner: &Owner, resumed_from: Option<OperationId>, ) -> Result<OperationRow>

Journals operation op on run as queued and started at once by owner (the command line, an embedder with no service), recovering resumed_from when it found that one unfinished.

§Errors

The store can’t be written.

Source

pub fn step( &mut self, id: OperationId, step: &str, state: StepState, ) -> Result<()>

Journals that step step of operation id reached state.

§Errors

The store can’t be written.

Source

pub fn steps(&self, id: OperationId) -> Result<Vec<(String, StepState)>>

Operation id’s journaled steps, in order: each step and where it reached.

§Errors

The store can’t be read.

Source

pub fn end_operation( &mut self, id: OperationId, outcome: Outcome, code: Option<ErrorCode>, ) -> Result<()>

Journals how operation id ended. An operation already ended keeps its first end. A queued one that never started can only be cancelled: it never ran.

§Errors

illegal_transition when a queued operation is ended otherwise than cancelled; the store’s.

Source

pub fn request_cancel(&mut self, id: OperationId) -> Result<bool>

Asks operation id to stop: false when it already ended.

§Errors

The store can’t be written.

Source

pub fn operation(&self, id: OperationId) -> Result<Option<OperationRow>>

Operation id.

§Errors

The store can’t be read, or the row holds what this runner doesn’t write.

Source

pub fn operations( &self, run: &RunName, limit: usize, ) -> Result<Vec<OperationRow>>

Run run’s last limit operations, newest first.

§Errors

As Tx::operation.

Source

pub fn in_flight(&self) -> Result<Vec<OperationRow>>

The home’s operations that never ended, every run’s, queued or started, oldest first: those still in their owner’s queue or running while it lives, else left by a process that died.

§Errors

As Tx::operation.

Source

pub fn unfinished(&self, run: &RunName) -> Result<Vec<OperationRow>>

Run run’s operations that never ended, queued or started, oldest first. Called with the run held (its lock, or its lease), so none of the started ones runs: each is one whose process died, or whose future was dropped before it could say how it ended. A queued one still waits in its owner’s queue while that owner lives.

§Errors

As Tx::operation.

Source

pub fn cancel_orphaned_queued(&mut self) -> Result<Vec<OperationId>>

Ends cancelled every queued operation of the home (any run) that never started and whose owner is gone (another boot, a dead process): a service that died with operations in its queue. Returns their ids. A live owner’s queued rows stay: they wait in its queue.

§Errors

The store can’t be read or written.

Source

pub fn append_event( &mut self, operation: Option<OperationId>, event: &Event, ) -> Result<EventCursor>

Appends event (of operation operation, if any) to the event table: its cursor.

§Errors

The store can’t be written.

Source

pub fn append_raw_event( &mut self, run: Option<&str>, operation: Option<OperationId>, body: &str, ) -> Result<EventCursor>

Appends an event already written as JSON, as written (another version’s kind): it is read back as an event when this runner reads it, else counted unreadable.

§Errors

The store can’t be written.

Source

pub fn events_after( &self, after: EventCursor, run: Option<&RunName>, limit: usize, ) -> Result<(Vec<(EventCursor, Event)>, usize)>

Up to limit events after cursor after, of run run or of every run, oldest first, with how many rows it couldn’t read as an event (another version’s kind).

§Errors

The store can’t be read.

Source

pub fn events_page( &self, after: EventCursor, run: Option<&RunName>, limit: usize, ) -> Result<EventPage>

Up to limit event rows after cursor after, of run run or of every run, oldest first: the events it reads, how many rows it couldn’t read as one, and the cursor of the last row it scanned, read or not (after when there was none). A reader resumes from last: a page of rows another version wrote, none of them readable, still moves it on.

§Errors

The store can’t be read.

Source

pub fn last_cursor(&self) -> Result<EventCursor>

The newest event’s cursor (0 when there is none).

§Errors

The store can’t be read.

Source

pub fn trim_events(&mut self, run: &RunName, keep: usize) -> Result<()>

Keeps run run’s newest keep events.

§Errors

The store can’t be written.

Source§

impl Tx<'_>

Source

pub fn lease(&self, scope: &str) -> Result<Option<Lease>>

Lease scope, when one is written (live or not).

§Errors

The store can’t be read.

Source

pub fn acquire_lease( &mut self, scope: &str, owner: &Owner, ttl: Duration, ) -> Result<LeaseOutcome>

Takes lease scope for owner for ttl: when nobody holds it, when its holder’s lease expired or its process is gone (taken over: the lease it left is returned), or when owner holds it already (renewed). A live holder keeps it.

§Errors

The store can’t be written.

Source

pub fn renew_lease( &mut self, scope: &str, owner: &Owner, ttl: Duration, ) -> Result<bool>

Extends owner’s lease scope by ttl from now: false when owner doesn’t hold it (another took it over).

§Errors

The store can’t be written.

Source

pub fn release_lease(&mut self, scope: &str, owner: &Owner) -> Result<()>

Lets go of owner’s lease scope (nothing when another holds it), and of the ports reserved under it.

§Errors

The store can’t be written.

Source

pub fn reserve_port( &mut self, reserver: &Reserver<'_>, port: HostPort, protocol: Protocol, ) -> Result<bool>

Reserves host port over protocol for reserver: false when another run’s live reservation holds it. A reservation whose lease is gone, expired or another’s now (its process died) is taken over.

§Errors

The store can’t be written.

Source

pub fn port_holder( &self, port: HostPort, protocol: Protocol, ) -> Result<Option<PortReservation>>

The live reservation of port over protocol, if one holds it: one whose lease its reserver still holds, live.

§Errors

The store can’t be read.

Source

pub fn release_ports(&mut self, by: OperationId) -> Result<()>

Frees every port operation by reserved.

§Errors

The store can’t be written.

Source

pub fn port_reservations(&self) -> Result<Vec<PortReservation>>

Every live reservation, by port.

§Errors

The store can’t be read.

Source§

impl Tx<'_>

Source

pub fn creating(&mut self, new: &NewResource<'_>) -> Result<ResourceId>

Writes new as creating, before the call that makes it: commit it before the call.

§Errors

illegal_transition when new gives a local kind a lifetime other than its own, or a provider kind none; the store’s.

Source

pub fn created(&mut self, id: ResourceId, native_id: &str) -> Result<()>

Records that resource id was made, as native_id.

§Errors

illegal_transition when the row isn’t creating or created (a made resource made again keeps its row: an idempotent retry); the store’s.

Source

pub fn destroying(&mut self, id: ResourceId, by: OperationId) -> Result<()>

Records that operation by is removing resource id: before the call that removes it.

§Errors

illegal_transition when the row is gone already; the store’s.

Source

pub fn gone(&mut self, id: ResourceId) -> Result<()>

Records that resource id is gone: removed, or found missing. Gone twice is fine.

§Errors

The store’s.

Source

pub fn resource(&self, id: ResourceId) -> Result<Option<ResourceRow>>

Resource row id, in any state.

§Errors

The store can’t be read.

Source

pub fn left_by_dead_operations( &self, run: &RunName, current: OperationId, ) -> Result<Vec<ResourceRow>>

The live provider rows of run that operations whose process died made: each made by an operation that ended abandoned, or never ended and isn’t current (called with the run held, so none of those runs). What a recovery removes by recorded id, newest first. A row still creating with no id is left out: nothing to remove by, and the next reading of what the tool reports gives it its id or lets it go.

§Errors

The store can’t be read.

Source

pub fn live_resources(&self, run: &RunName) -> Result<Vec<ResourceRow>>

Run run’s resources not gone, oldest first (a down walks them newest first).

§Errors

The store can’t be read.

Source

pub fn resources_of(&self, by: OperationId) -> Result<Vec<ResourceRow>>

The resources operation by made that aren’t gone: what a recovery of it removes.

§Errors

The store can’t be read.

Source

pub fn resource_named( &self, run: &RunName, key: &str, name: &CopyName, ) -> Result<Option<ResourceRow>>

Run run’s live resource keyed key of the per-copy name name: what an idempotent create finds before making it again. Never by a bare name: CopyName holds the key.

§Errors

The store can’t be read.

Source§

impl Tx<'_>

Source

pub fn run(&self, name: &RunName) -> Result<Option<RunRow>>

Run name’s row, when it has one.

§Errors

The store can’t be read, or the row holds what this runner doesn’t write.

Source

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

Every run’s row, by name.

§Errors

As Tx::run.

Source

pub fn save_record( &mut self, record: &RunRecord, desired: Desired, ) -> Result<()>

Records record: a new run’s row is made in the record’s state (absent for a run never started; another for an imported one), wanting desired; an existing row gets the record’s fields and keeps its state, which only Tx::apply moves.

§Errors

The store can’t be written.

Source

pub fn set_source_digest(&mut self, name: &RunName, digest: &str) -> Result<()>

Records the digest of the project files run name now runs from (crate::Project::digest).

§Errors

The store can’t be written.

Source

pub fn set_desired(&mut self, name: &RunName, desired: Desired) -> Result<()>

Sets what the user wants of run name.

§Errors

The store can’t be written.

Source

pub fn apply(&mut self, name: &RunName, transition: Transition) -> Result<()>

Moves run name by transition, and keeps the move with what made it. A compare-and-set: refused (state_conflict) when the run no longer stands where the transition starts.

§Errors

state_conflict when the run moved meanwhile or has no row; the store’s.

Source

pub fn transitions( &self, name: &RunName, ) -> Result<Vec<(RunState, RunState, Option<OperationId>)>>

Run name’s moves, oldest first: from, to, the operation that made each (none for an observation).

§Errors

The store can’t be read.

Source

pub fn keep_observed( &mut self, name: &RunName, observed: &LastObserved, ) -> Result<bool>

Keeps observed as what the runner last saw of run name (no row: nothing kept), its state left as it is: an operation’s own reads.

§Errors

The store can’t be written.

Source

pub fn observe( &mut self, name: &RunName, observed: &LastObserved, to: RunState, ) -> Result<Option<Transition>>

Status = reconcile(desired, observed): keeps observed, and when a settled run shows as to (what its machines say), moves it there by an observation. A moving run (an operation owns it) or a move the table doesn’t allow keeps its state. The move made, if one was.

§Errors

The store can’t be written.

Source

pub fn forget_observed(&mut self, name: &RunName) -> Result<()>

Forgets what the runner last saw of run name.

§Errors

The store can’t be written.

Source

pub fn forget_run(&mut self, name: &RunName) -> Result<()>

Removes run name’s row and its moves.

§Errors

The store can’t be written.

Auto Trait Implementations§

§

impl<'c> !RefUnwindSafe for Tx<'c>

§

impl<'c> !Send for Tx<'c>

§

impl<'c> !Sync for Tx<'c>

§

impl<'c> !UnwindSafe for Tx<'c>

§

impl<'c> Forget for Tx<'c>

§

impl<'c> Freeze for Tx<'c>
where &'c Connection: Freeze,

§

impl<'c> Move for Tx<'c>

§

impl<'c> Unpin for Tx<'c>
where &'c Connection: Unpin,

§

impl<'c> UnsafeUnpin for Tx<'c>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more