radicle_ci_broker::db

Struct Db

Source
pub struct Db { /* private fields */ }
Expand description

The CI broker database. It stores the data that needs to be persistent, even if the process terminates.

Implementations§

Source§

impl Db

Source

pub fn new<P: AsRef<Path>>(filename: P) -> Result<Self, DbError>

Open or create a database. It is created if it doesn’t exist. If it is created, tables are created.

Source

pub fn filename(&self) -> &Path

Name of database file.

Source

pub fn begin(&self) -> Result<(), DbError>

Start a transaction.

Source

pub fn commit(&self) -> Result<(), DbError>

Commit a transaction.

Source

pub fn rollback(&self) -> Result<(), DbError>

Roll back a transaction.

Source

pub fn create_counter(&self, counter: i64) -> Result<(), DbError>

Create the counter with an initial value. Only use this if there isn’t a counter row already.

Source

pub fn update_counter(&self, counter: i64) -> Result<(), DbError>

Update the counter to have a new value.

Source

pub fn get_counter(&self) -> Result<Option<i64>, DbError>

Return the current value of the counter, if any.

Source

pub fn queued_events(&self) -> Result<Vec<QueueId>, DbError>

Return list of identifiers for broker events currently in the queue.

Note that there is no longer any way to retrieve the broker events. This method is meant only for making sure there are no unprocessed broker events in the queue.

Source

pub fn queued_ci_events(&self) -> Result<Vec<QueueId>, DbError>

Return list of identifiers for CI events currently in the queue.

Source

pub fn get_queued_ci_event( &self, id: &QueueId, ) -> Result<Option<QueuedCiEvent>, DbError>

Return a specific event, given is id, if one exists.

Source

pub fn push_queued_ci_event(&self, event: CiEvent) -> Result<QueueId, DbError>

Add a new event to the event queue, returning its id.

Source

pub fn remove_queued_ci_event(&self, id: &QueueId) -> Result<(), DbError>

Remove CI event from queue, given its id. It’s OK if the event is not in the queue, that is just silently ignored.

Source

pub fn list_runs(&self) -> Result<Vec<RunId>, DbError>

Return list of CI runs currently in the database.

Source

pub fn get_all_runs(&self) -> Result<Vec<Run>, DbError>

Return all CI runs currently in the database.

Source

pub fn get_run(&self, id: &RunId) -> Result<Option<Run>, DbError>

Return a specific CI run, given is id, if one exists.

Source

pub fn find_runs(&self, adapter_runid: &RunId) -> Result<Vec<Run>, DbError>

Return a list of broker run IDs that their adapter run ID set to a given value.

Source

pub fn push_run(&self, run: &Run) -> Result<RunId, DbError>

Add a new CI run to the database, returning its id.

Source

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

Update a CI run in the database.

Source

pub fn remove_run(&self, id: &RunId) -> Result<(), DbError>

Remove a CI run from database, given its id. It’s OK if the run is not in the database, that is just silently ignored.

Auto Trait Implementations§

§

impl Freeze for Db

§

impl !RefUnwindSafe for Db

§

impl Send for Db

§

impl !Sync for Db

§

impl Unpin for Db

§

impl !UnwindSafe for Db

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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T