pub struct Worker { /* private fields */ }Expand description
A worker: its settings, identity and CLI.
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn new(cfg: Config) -> Result<Self, Fatal>
pub fn new(cfg: Config) -> Result<Self, Fatal>
A worker for cfg, with the identity kept in its data directory,
made there if this is the first start. Refuses an identity made for
another server.
Sourcepub fn identity(&self) -> &Identity
pub fn identity(&self) -> &Identity
Its identity: key fingerprint, and device id once approved.
Sourcepub async fn run(self, shutdown: impl Future<Output = ()>) -> Result<(), Fatal>
pub async fn run(self, shutdown: impl Future<Output = ()>) -> Result<(), Fatal>
Checks the server, enrols until the owner approves, then runs jobs
until shutdown resolves. Returns only on shutdown, or on something
a person has to fix.
Sourcepub async fn check_server(&mut self) -> Result<(), Fatal>
pub async fn check_server(&mut self) -> Result<(), Fatal>
Reads the server’s discovery document, and goes on only if the server lists the merge queue. An answer that says this is not such a server is final; one that says nothing (the server is restarting, or not up yet) is asked again.
Sourcepub async fn enrol(&mut self) -> Result<(), Fatal>
pub async fn enrol(&mut self) -> Result<(), Fatal>
Enrols by the device flow: asks for a code, prints it with the key fingerprint, and polls until the owner approves it. A restart while waiting keeps polling the same enrolment.
Sourcepub fn claim_request(&self) -> ClaimRequest
pub fn claim_request(&self) -> ClaimRequest
The claim this worker sends now: every kind it can do, and that CLI’s last check. No merges while its CLI cannot merge; evaluations whenever the server makes them, since all their checks but the contradiction check run without the CLI.
Sourcepub async fn step(&mut self) -> Result<Step, ApiError>
pub async fn step(&mut self) -> Result<Step, ApiError>
One claim, and the job it brought, if any.
Sourcepub async fn work(&mut self, job: &Job) -> ResultRequest
pub async fn work(&mut self, job: &Job) -> ResultRequest
Does one job, and says what to report.
A merge that fails has the CLI checked again before the next claim, rather than at the next scheduled check: a CLI that was logged out under the worker should stop it taking jobs now, not in half an hour.