pub struct Server { /* private fields */ }Expand description
The HTTP API, its background jobs, and the state they share.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(cfg: Config, store: Arc<Store>) -> Self
pub fn new(cfg: Config, store: Arc<Store>) -> Self
Builds a server around an already-open store.
Sourcepub fn router(&self) -> Router
pub fn router(&self) -> Router
The router, built separately from binding a port so tests can drive it without real sockets.
Sourcepub async fn refresh_claude_status(&self)
pub async fn refresh_claude_status(&self)
Re-runs the local claude auth status probe.
Sourcepub fn claude_status(&self) -> Status
pub fn claude_status(&self) -> Status
The last known state of the claude CLI.
Sourcepub fn set_claude_status(&self, status: Status)
pub fn set_claude_status(&self, status: Status)
Overrides the cached CLI status.
Exposed so tests can exercise the merge-failure path — reaching it otherwise needs a real, logged-in CLI on the machine running them.
Sourcepub fn run_backup(&self)
pub fn run_backup(&self)
Writes a backup now. Failure is logged, never propagated: it becomes
visible through /health’s last_backup_at going stale.
Sourcepub fn start_background(&self) -> Vec<JoinHandle<()>>
pub fn start_background(&self) -> Vec<JoinHandle<()>>
Starts background work: the first Claude CLI status check, its refresh loop, and backups. All of it is best-effort — none of it may take the sync API down.
Sourcepub async fn serve(&self) -> Result<()>
pub async fn serve(&self) -> Result<()>
Binds cfg.addr and serves until SIGTERM or ctrl-c, then shuts down
gracefully so an in-flight merge isn’t cut off mid-write.
Sourcepub async fn serve_with_shutdown<F>(
&self,
listener: TcpListener,
shutdown: F,
) -> Result<()>
pub async fn serve_with_shutdown<F>( &self, listener: TcpListener, shutdown: F, ) -> Result<()>
Serves on an already-bound listener until shutdown resolves.