From bd2ebe9396475632908b23d8263be70166197dc2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Sep 2025 22:03:54 +0900 Subject: feat(worker-swift): compile and run in one request --- backend/taskqueue/processor.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'backend/taskqueue') diff --git a/backend/taskqueue/processor.go b/backend/taskqueue/processor.go index 8dadfdf..c4cf60b 100644 --- a/backend/taskqueue/processor.go +++ b/backend/taskqueue/processor.go @@ -3,6 +3,7 @@ package taskqueue import ( "bytes" "context" + "crypto/md5" "encoding/json" "fmt" "net/http" @@ -16,6 +17,7 @@ func newProcessor() processor { type testrunRequestData struct { Code string `json:"code"` + CodeHash string `json:"code_hash"` Stdin string `json:"stdin"` MaxDuration int `json:"max_duration_ms"` } @@ -32,6 +34,7 @@ func (p *processor) doProcessTaskRunTestcase( ) (*TaskResultRunTestcase, error) { reqData := testrunRequestData{ Code: payload.Code, + CodeHash: calcCodeHash(payload.Code), Stdin: payload.Stdin, MaxDuration: 5000, } @@ -64,3 +67,7 @@ func (p *processor) doProcessTaskRunTestcase( Stderr: resData.Stderr, }, nil } + +func calcCodeHash(code string) string { + return fmt.Sprintf("%x", md5.Sum([]byte(code))) +} -- cgit v1.2.3-70-g09d2