Fix and add documentation

This commit is contained in:
Joscha 2023-08-13 01:11:31 +02:00
parent 0bad08eca9
commit 08e240d7db
3 changed files with 7 additions and 6 deletions

View file

@ -91,7 +91,7 @@ impl Workers {
} }
pub fn should_abort_work(&self, name: &str, queue: &[String]) -> bool { pub fn should_abort_work(&self, name: &str, queue: &[String]) -> bool {
// A runner should abort work if... // A worker should abort work if...
let Some(info) = self.workers.get(name) else { return false; }; let Some(info) = self.workers.get(name) else { return false; };
let WorkerStatus::Working (unfinished) = &info.status else { return false; }; let WorkerStatus::Working (unfinished) = &info.status else { return false; };
@ -100,7 +100,7 @@ impl Workers {
return true; return true;
} }
// Another runner has been working on the same commit for longer // Another worker has been working on the same commit for longer
let oldest_working_on_commit = self let oldest_working_on_commit = self
.workers .workers
.iter() .iter()

View file

@ -101,7 +101,7 @@ pub struct WorkerRequest {
/// The worker wants a new run from the server. /// The worker wants a new run from the server.
/// ///
/// If the server has a commit available, it should respond with a non-null /// If the server has a commit available, it should respond with a non-null
/// [`ServerResponse::work`]. /// [`ServerResponse::run`].
#[serde(default, skip_serializing_if = "is_false")] #[serde(default, skip_serializing_if = "is_false")]
pub request_run: bool, pub request_run: bool,
@ -112,7 +112,7 @@ pub struct WorkerRequest {
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct ServerResponse { pub struct ServerResponse {
/// Run the worker requested using [`RunnerRequest::request_run`]. /// Run the worker requested using [`WorkerRequest::request_run`].
/// ///
/// The worker may ignore this run and do something else. However, until the /// The worker may ignore this run and do something else. However, until the
/// next update request sent by the worker, the server will consider the /// next update request sent by the worker, the server will consider the

View file

@ -28,7 +28,7 @@ pub struct Server {
/// while processing the response. /// while processing the response.
/// ///
/// This lock prevents the following race condition that would lead to /// This lock prevents the following race condition that would lead to
/// multiple runners receiving runs for the same commit in unlucky /// multiple workers receiving runs for the same commit in unlucky
/// circumstances: /// circumstances:
/// ///
/// 1. The main task requests a run /// 1. The main task requests a run
@ -40,7 +40,8 @@ pub struct Server {
} }
impl Server { impl Server {
// TODO Limit status requests to one in flight at a time (per server) /// **Important:** Before using this function, read the documentation of
/// [`Self::status_lock`]!
pub async fn post_status( pub async fn post_status(
&self, &self,
request_run: bool, request_run: bool,