pub struct DeviceJoinJournalStore { /* private fields */ }Expand description
The joining device’s own journal of in-flight join attempts, kept in its own SQLite file under the stores root because the Store database it is joining does not exist yet while the attempt runs.
The file lives exactly as long as the attempts in it. Retiring the last row closes the connection and deletes the file with its WAL sidecars, so a device that has joined a store does not leave a dead journal behind forever; the next attempt reopens the path and gets a new file.
Implementations§
Source§impl DeviceJoinJournalStore
impl DeviceJoinJournalStore
pub fn open(path: impl AsRef<Path>) -> Result<Self, DbError>
pub fn open_for_test(path: impl AsRef<Path>) -> Result<Self, DbError>
pub fn insert_or_load( &self, attempt_id: &str, role: &str, payload: &str, ) -> Result<String, DbError>
pub fn load( &self, attempt_id: &str, role: &str, ) -> Result<Option<String>, DbError>
pub fn records(&self) -> Result<Vec<(String, String, String)>, DbError>
pub fn compare_and_swap( &self, attempt_id: &str, role: &str, previous_payload: &str, next_payload: &str, ) -> Result<bool, DbError>
Sourcepub fn compare_and_forget(
&self,
attempt_id: &str,
role: &str,
expected_payload: &str,
) -> Result<bool, DbError>
pub fn compare_and_forget( &self, attempt_id: &str, role: &str, expected_payload: &str, ) -> Result<bool, DbError>
Drop one attempt’s joiner row, but only while it still holds exactly the payload the caller last read, and delete the journal file when that row was the last one in it.
This is how a joining device finishes: the row is its working notes on an exchange that is over, and what says the join happened is the library’s own config file, written before this runs. An emptied journal answers nothing either, so the file goes with the row rather than accumulating one dead SQLite database per store the device ever joined.
The row delete, the emptiness check, and the unlink all happen under the one connection lock, so a row begun by another attempt cannot land in a file that is about to be deleted.
Trait Implementations§
Source§impl Clone for DeviceJoinJournalStore
impl Clone for DeviceJoinJournalStore
Source§fn clone(&self) -> DeviceJoinJournalStore
fn clone(&self) -> DeviceJoinJournalStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more