From a876e5dfec331c1b6a921c9dd1b79d9d6917ebbd Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 2 Jul 2023 16:14:23 -0700 Subject: add host identifiers? --- src/ci_driver.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/ci_driver.rs') diff --git a/src/ci_driver.rs b/src/ci_driver.rs index c6bef14..d8e60e5 100644 --- a/src/ci_driver.rs +++ b/src/ci_driver.rs @@ -109,12 +109,12 @@ async fn activate_run(dbctx: Arc, run: &PendingRun, clients: &mut mpsc::R } }; - let run_host = client_job.client.name.clone(); + let host_id = client_job.client.host_id; let connection = dbctx.conn.lock().unwrap(); connection.execute( - "update runs set started_time=?1, run_host=?2, state=1, artifacts_path=?3, build_token=?4 where id=?5", - (now as u64, run_host, format!("{}", artifacts.display()), &client_job.client.build_token, run.id) + "update runs set started_time=?1, host_id=?2, state=1, artifacts_path=?3, build_token=?4 where id=?5", + (now as u64, host_id, format!("{}", artifacts.display()), &client_job.client.build_token, run.id) ) .expect("can update"); std::mem::drop(connection); @@ -129,15 +129,11 @@ async fn activate_run(dbctx: Arc, run: &PendingRun, clients: &mut mpsc::R struct RunnerClient { tx: mpsc::Sender>, rx: BodyStream, - name: String, + host_id: u32, build_token: String, accepted_sources: Option>, } -fn random_name() -> String { - "random name".to_string() -} - fn token_for_job() -> String { let mut data = [0u8; 32]; std::fs::File::open("/dev/urandom") @@ -250,13 +246,12 @@ impl ClientJob { } impl RunnerClient { - async fn new(sender: mpsc::Sender>, resp: BodyStream, accepted_sources: Option>) -> Result { - let name = random_name(); + async fn new(sender: mpsc::Sender>, resp: BodyStream, accepted_sources: Option>, host_id: u32) -> Result { let token = token_for_job(); let client = RunnerClient { tx: sender, rx: resp, - name, + host_id, build_token: token, accepted_sources, }; @@ -455,7 +450,9 @@ async fn handle_next_job(State(ctx): State<(Arc, mpsc::Sender v, Err(e) => { eprintln!("unable to register client"); -- cgit v1.1