broker: sqlite-backed (survives hive-c0re restart)
This commit is contained in:
parent
af464e27f4
commit
d220720f6a
6 changed files with 90 additions and 27 deletions
|
|
@ -2,7 +2,7 @@
|
|||
//! sockets: the broker plus a map of `name -> AgentSocket`.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
|
@ -18,11 +18,12 @@ pub struct Coordinator {
|
|||
}
|
||||
|
||||
impl Coordinator {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
broker: Arc::new(Broker::new()),
|
||||
pub fn open(db_path: &Path) -> Result<Self> {
|
||||
let broker = Broker::open(db_path).context("open broker")?;
|
||||
Ok(Self {
|
||||
broker: Arc::new(broker),
|
||||
agents: Mutex::new(HashMap::new()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn register_agent(&self, name: &str) -> Result<PathBuf> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue