From 18a971aaa83eb1f1917e195e39dfd6fa22e020fa Mon Sep 17 00:00:00 2001 From: zztrans <2438362589@qq.com> Date: Sun, 22 Sep 2024 20:33:15 +0800 Subject: [PATCH] add judge UID for judgetask --- judger/src/agent/platform/mod.rs | 7 ++++++- judger/src/worker/mod.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/judger/src/agent/platform/mod.rs b/judger/src/agent/platform/mod.rs index 00026f8..02527df 100644 --- a/judger/src/agent/platform/mod.rs +++ b/judger/src/agent/platform/mod.rs @@ -43,10 +43,11 @@ impl PlatformClient { pub async fn report_judge_task( &self, + judge_uid: &str, stream_id: &str, verdict: JudgeVerdict, ) -> Result<(), anyhow::Error> { - report_task(&self.client, stream_id, verdict).await + report_task(&self.client, judge_uid, stream_id, verdict).await } } @@ -163,6 +164,8 @@ async fn report_judge_result( #[derive(Serialize)] struct ReportJudgeTaskBody { + #[serde(rename = "judgeUID")] + judge_uid: String, consumer: String, #[serde(rename = "redisStreamID")] redis_stream_id: String, @@ -175,11 +178,13 @@ struct ReportJudgeTaskResponse { async fn report_task( client: &HttpClient, + judge_uid: &str, stream_id: &str, verdict: JudgeVerdict, ) -> Result<(), anyhow::Error> { let report_url = "api/v1/judge/task/report"; let body = ReportJudgeTaskBody { + judge_uid: judge_uid.to_owned(), consumer: "".to_string(), redis_stream_id: stream_id.to_owned(), verdict, diff --git a/judger/src/worker/mod.rs b/judger/src/worker/mod.rs index 772bdcf..1ba9ef5 100644 --- a/judger/src/worker/mod.rs +++ b/judger/src/worker/mod.rs @@ -84,7 +84,11 @@ impl JudgeWorker { verdict = JudgeVerdict::CompileError; } let _ = platform_client - .report_judge_task(&task.redis_stream_id.clone(), verdict) + .report_judge_task( + &task.judge_uid, + &task.redis_stream_id.clone(), + verdict, + ) .await .map_err(|e| { log::debug!("Failed to report judge task: {:?}", e); @@ -149,7 +153,7 @@ impl JudgeWorker { } let _ = platform_client - .report_judge_task(&task.redis_stream_id.clone(), verdict) + .report_judge_task(&task.judge_uid, &task.redis_stream_id.clone(), verdict) .await .map_err(|e| { log::debug!("Failed to report judge task: {:?}", e);