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. Nothing is recorded
yet: the start leaf waits until the server is serving (see
Server::serve_with_shutdown).
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 backdate_last_claim(&self, seconds: u64)
pub fn backdate_last_claim(&self, seconds: u64)
Makes the last claim by a worker, or this server’s start if there
has been none, seconds older than it is.
Exposed so tests can reach a worker whose claims have stopped without waiting minutes for it.
Sourcepub async fn drain_jobs(&self) -> Result<()>
pub async fn drain_jobs(&self) -> Result<()>
Merges the jobs left in the queue here, or marks them failed when this server cannot merge, if no worker is enrolled; otherwise does nothing. Run by itself when the last worker is revoked and on every sweep; exposed so tests can wait for it.
Sourcepub fn run_scheduled_evaluation(&self) -> Result<Option<String>>
pub fn run_scheduled_evaluation(&self) -> Result<Option<String>>
Queues the run RECALL_EVAL_INTERVAL_HOURS asks for: every project,
never the contradiction check. Skipped, answering None, while no
worker is enrolled or another run is open. Run by itself on the
schedule; exposed so tests need not wait an hour for it.
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 issue_bootstrap_code(&self) -> Result<Option<BootstrapCode>>
pub fn issue_bootstrap_code(&self) -> Result<Option<BootstrapCode>>
Issues a new bootstrap code, when passkey sign-in is on and no
passkey is registered: the one-time code that, with RECALL_TOKEN,
registers the first. None otherwise. recall-server calls it on
start and prints what it gets; see crate::bootstrap.
Sourcepub fn public_url(&self) -> Option<&str>
pub fn public_url(&self) -> Option<&str>
Where the admin page is, when RECALL_PUBLIC_URL says.
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, the device sweep, and draining a queue no worker is left to take. 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, and empties
the WAL into the database file (Store::checkpoint_all).
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).
Once the transport is ready, records a start leaf in the audit
log: the server’s own doing, so its actor is
crate::audit::leaf::Actor::Server, and its subject the version
that started. Here rather than in Server::new so that only a
server that got its port, and its certificate, records one: one that
failed to bind because another was still running, or to load its
key, leaves nothing. Best-effort — a store the audit table somehow
cannot be written to still serves sync, the same way a failed backup
does not take the server down.
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> 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<'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