mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-11 01:53:23 +01:00
Move MachineDB into LMDB
This commit is contained in:
parent
76ccddb4cb
commit
4fde079986
@ -158,7 +158,27 @@ impl Machine {
|
||||
}
|
||||
}
|
||||
|
||||
pub type MachineDB = HashMap<Uuid, Machine>;
|
||||
struct MachineDB {
|
||||
db: lmdb::Database,
|
||||
}
|
||||
|
||||
impl MachineDB {
|
||||
pub fn new(db: lmdb::Database) -> Self {
|
||||
Self { db }
|
||||
}
|
||||
|
||||
pub fn get_machine<T: Transaction>(&self, txn: &T, machine_id: MachineIdentifier)
|
||||
-> Result<Option<Machine>>
|
||||
{
|
||||
match txn.get(self.db, &machine_id.to_ne_bytes()) {
|
||||
Ok(bytes) => {
|
||||
Ok(Some(flexbuffers::from_slice(bytes)?))
|
||||
},
|
||||
Err(lmdb::Error::NotFound) => { Ok(None) },
|
||||
Err(e) => { Err(e.into()) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn init(log: Logger, config: &Settings) -> Result<MachinesProvider> {
|
||||
unimplemented!()
|
||||
|
Loading…
Reference in New Issue
Block a user