pub struct Deployments { /* private fields */ }Expand description
Handle to the deployments system, wrapping a DatabaseConnection.
All methods bind caller-supplied strings as Value::* parameters — no
string interpolation (T-186-04).
Implementations§
Source§impl Deployments
impl Deployments
Sourcepub fn new(db: DatabaseConnection) -> Self
pub fn new(db: DatabaseConnection) -> Self
Create a new Deployments handle backed by db.
Sourcepub async fn create(
&self,
owner_key: &str,
source_ref: Option<&str>,
) -> Result<Deployment, Error>
pub async fn create( &self, owner_key: &str, source_ref: Option<&str>, ) -> Result<Deployment, Error>
Insert a new deployment row with status building.
Returns the complete Deployment row including its assigned id.
Sourcepub async fn mark_ready(
&self,
id: i64,
artifact_location: &str,
byte_size: i64,
) -> Result<(), Error>
pub async fn mark_ready( &self, id: i64, artifact_location: &str, byte_size: i64, ) -> Result<(), Error>
Transition a building deployment to ready, recording the artifact
location and byte size.
Returns Err when the row does not exist or is already in a terminal
state (ready or failed).
Sourcepub async fn mark_failed(&self, id: i64, error: &str) -> Result<(), Error>
pub async fn mark_failed(&self, id: i64, error: &str) -> Result<(), Error>
Transition a building deployment to failed.
The error message is emitted as a tracing warning (no error column in
the schema). Returns Err when the row does not exist or is already
terminal.
Sourcepub async fn get(&self, id: i64) -> Result<Deployment, Error>
pub async fn get(&self, id: i64) -> Result<Deployment, Error>
Fetch a deployment by its primary key.
Sourcepub async fn list(&self, owner_key: &str) -> Result<Vec<Deployment>, Error>
pub async fn list(&self, owner_key: &str) -> Result<Vec<Deployment>, Error>
List all deployments for owner_key, newest first.
Sourcepub async fn active(&self, owner_key: &str) -> Result<Option<Deployment>, Error>
pub async fn active(&self, owner_key: &str) -> Result<Option<Deployment>, Error>
Return the currently-active deployment for owner_key, or None when
no pointer row exists yet.
Sourcepub async fn promote(
&self,
owner_key: &str,
deployment_id: i64,
) -> Result<Option<i64>, Error>
pub async fn promote( &self, owner_key: &str, deployment_id: i64, ) -> Result<Option<i64>, Error>
Atomically promote deployment_id to be the active deployment for
owner_key.
Guards:
Error::NotReadywhen the deployment status is notready.Error::ArtifactDeletedwhenartifact_deleted_atis set.
Returns the previously-active deployment id, or None when this is the
first promotion.
Trait Implementations§
Source§impl Clone for Deployments
impl Clone for Deployments
Source§fn clone(&self) -> Deployments
fn clone(&self) -> Deployments
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Deployments
impl !UnwindSafe for Deployments
impl Freeze for Deployments
impl Send for Deployments
impl Sync for Deployments
impl Unpin for Deployments
impl UnsafeUnpin for Deployments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more