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
impl Db
Sourcepub fn new<P: AsRef<Path>>(filename: P) -> Result<Self, DbError>
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.
Sourcepub fn create_counter(&self, counter: i64) -> Result<(), DbError>
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.
Sourcepub fn update_counter(&self, counter: i64) -> Result<(), DbError>
pub fn update_counter(&self, counter: i64) -> Result<(), DbError>
Update the counter to have a new value.
Sourcepub fn get_counter(&self) -> Result<Option<i64>, DbError>
pub fn get_counter(&self) -> Result<Option<i64>, DbError>
Return the current value of the counter, if any.
Sourcepub fn queued_events(&self) -> Result<Vec<QueueId>, DbError>
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.
Sourcepub fn queued_ci_events(&self) -> Result<Vec<QueueId>, DbError>
pub fn queued_ci_events(&self) -> Result<Vec<QueueId>, DbError>
Return list of identifiers for CI events currently in the queue.
Sourcepub fn get_queued_ci_event(
&self,
id: &QueueId,
) -> Result<Option<QueuedCiEvent>, DbError>
pub fn get_queued_ci_event( &self, id: &QueueId, ) -> Result<Option<QueuedCiEvent>, DbError>
Return a specific event, given is id, if one exists.
Sourcepub fn push_queued_ci_event(&self, event: CiEvent) -> Result<QueueId, DbError>
pub fn push_queued_ci_event(&self, event: CiEvent) -> Result<QueueId, DbError>
Add a new event to the event queue, returning its id.
Sourcepub fn remove_queued_ci_event(&self, id: &QueueId) -> Result<(), DbError>
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.
Sourcepub fn list_runs(&self) -> Result<Vec<RunId>, DbError>
pub fn list_runs(&self) -> Result<Vec<RunId>, DbError>
Return list of CI runs currently in the database.
Sourcepub fn get_all_runs(&self) -> Result<Vec<Run>, DbError>
pub fn get_all_runs(&self) -> Result<Vec<Run>, DbError>
Return all CI runs currently in the database.
Sourcepub fn get_run(&self, id: &RunId) -> Result<Option<Run>, DbError>
pub fn get_run(&self, id: &RunId) -> Result<Option<Run>, DbError>
Return a specific CI run, given is id, if one exists.
Sourcepub fn find_runs(&self, adapter_runid: &RunId) -> Result<Vec<Run>, DbError>
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.