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 set_clock_offset(&self, seconds: i64)
pub fn set_clock_offset(&self, seconds: i64)
Moves the clock device signatures are judged by, in seconds.
Exposed so tests can reach the edges of the signature window, and what happens after it, without waiting a minute for each.
Sourcepub fn backdate_start(&self, seconds: i64)
pub fn backdate_start(&self, seconds: i64)
Makes this server act as if it had started seconds earlier than
it did.
Exposed so tests can sign requests at once, rather than waiting out the few seconds after a start in which every signature is refused.
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 sweep_devices(&self) -> Result<(usize, usize)>
pub fn sweep_devices(&self) -> Result<(usize, usize)>
Removes ephemeral devices idle for longer than
Config::ephemeral_device_ttl, and enrolments that expired over
an hour ago. Answers how many of each went.
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, backups, and the device sweep. 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, in
whichever transport cfg.tls names (see server/tls.rs; plain HTTP,
the default, still goes through axum::serve directly, unchanged).
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
impl UnwindSafe for Server
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more