Skip to content

Commit

Permalink
Add run meta info in Run response
Browse files Browse the repository at this point in the history
  • Loading branch information
halabooda committed Feb 18, 2025
1 parent c8bc044 commit f7723ce
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 226 deletions.
32 changes: 20 additions & 12 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,11 @@ components:
type: array
items:
$ref: '#/components/schemas/SubmissionResponseEvents'
Time:
type: string
Errors:
type: array
items:
type: string
Meta:
type: object
properties:
Version:
type: string
additionalProperties: true
RunEnvironment:
$ref: '#/components/schemas/RunEnvironment'
required:
- Events
- RunEnvironment

SubmissionResponseEvents:
type: object
Expand All @@ -209,6 +200,20 @@ components:
- Message
- Kind

RunEnvironment:
type: object
properties:
compileCmd:
type: string
runCmd:
type: string
runTime:
type: number
required:
- compileCmd
- runCmd
- runTime

SandboxResponse:
type: object
properties:
Expand All @@ -222,10 +227,13 @@ components:
stderr:
type: string
format: byte
RunEnvironment:
$ref: '#/components/schemas/RunEnvironment'
required:
- exitCode
- stdout
- stderr
- RunEnvironment

SandboxRequest:
type: object
Expand Down
101 changes: 14 additions & 87 deletions api/gen/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 28 additions & 19 deletions docs/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,13 @@
"$ref": "#/components/schemas/SubmissionResponseEvents"
}
},
"Time": {
"type": "string"
},
"Errors": {
"type": "array",
"items": {
"type": "string"
}
},
"Meta": {
"type": "object",
"properties": {
"Version": {
"type": "string"
}
},
"additionalProperties": true
"RunEnvironment": {
"$ref": "#/components/schemas/RunEnvironment"
}
},
"required": [
"Events"
"Events",
"RunEnvironment"
]
},
"SubmissionResponseEvents": {
Expand All @@ -249,6 +235,25 @@
"Kind"
]
},
"RunEnvironment": {
"type": "object",
"properties": {
"compileCmd": {
"type": "string"
},
"runCmd": {
"type": "string"
},
"runTime": {
"type": "number"
}
},
"required": [
"compileCmd",
"runCmd",
"runTime"
]
},
"SandboxResponse": {
"type": "object",
"properties": {
Expand All @@ -265,12 +270,16 @@
"stderr": {
"type": "string",
"format": "byte"
},
"RunEnvironment": {
"$ref": "#/components/schemas/RunEnvironment"
}
},
"required": [
"exitCode",
"stdout",
"stderr"
"stderr",
"RunEnvironment"
]
},
"SandboxRequest": {
Expand Down
9 changes: 5 additions & 4 deletions internal/handler/handler_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ func runCode(ctx context.Context, req api.SubmissionRequest, backendURL string)
_ = resp.Body.Close()
}()

// TODO:: [HOOK] post-response hook

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected http status from backend: %d", resp.StatusCode)
}
Expand All @@ -200,8 +198,11 @@ func runCode(ctx context.Context, req api.SubmissionRequest, backendURL string)

apiRes := &api.SubmissionResponse{
Events: events,
Meta: nil,
Time: nil,
RunEnvironment: api.RunEnvironment{
RunCmd: execRes.RunEnvironment.RunCmd,
CompileCmd: execRes.RunEnvironment.CompileCmd,
RunTime: execRes.RunEnvironment.RunTime,
},
}

return apiRes, nil
Expand Down
Loading

0 comments on commit f7723ce

Please sign in to comment.