feat(runner): add the own code runner contract, client and nsjail service
This commit is contained in:
1 parent
5e1db37746
commit
cdf6bcbb91
109 files changed
+24084
-28
No files matched your search
@@ -0,0 +1,77 @@
|
||||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Handler handles operations described by OpenAPI v3 specification.
|
||||
type Handler interface {
|
||||
// GetRun implements GetRun operation.
|
||||
//
|
||||
// Answers 404 `not_found` for an ID the runner does not hold, including a run forgotten after its
|
||||
// retention time or lost in a restart.
|
||||
//
|
||||
// GET /v1/runs/{run_id}
|
||||
GetRun(ctx context.Context, params GetRunParams) (*RunStatus, error)
|
||||
// GetRunnerHealthz implements GetRunnerHealthz operation.
|
||||
//
|
||||
// Check whether the runner process is responding.
|
||||
//
|
||||
// GET /healthz
|
||||
GetRunnerHealthz(ctx context.Context) (*RunnerHealthResponse, error)
|
||||
// GetRunnerReadyz implements GetRunnerReadyz operation.
|
||||
//
|
||||
// Ready means that the cgroup hierarchy, the work directory, and the sandbox binary were prepared at
|
||||
// startup and the process is not draining. A busy runner is still ready; busy is reported by
|
||||
// SubmitRun.
|
||||
//
|
||||
// GET /readyz
|
||||
GetRunnerReadyz(ctx context.Context) (GetRunnerReadyzRes, error)
|
||||
// SubmitRun implements SubmitRun operation.
|
||||
//
|
||||
// Idempotent by `run_id`:
|
||||
//
|
||||
// - a new ID with a free sandbox slot starts the run and answers 202 with `state: running`;
|
||||
// - the same ID with the same payload answers 200 with the current state of that run, including the
|
||||
// finished result, without running it again;
|
||||
// - the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing;
|
||||
// - a new ID while every slot is busy, or while the runner is draining, answers 503 `runner_busy`
|
||||
// with Retry-After; nothing is stored, so the caller retries with the same ID.
|
||||
//
|
||||
// Payloads are compared by a SHA-256 fingerprint of the decoded request. The runner keeps runs only in
|
||||
// memory for a bounded time after they finish; an ID that was forgotten or lost in a restart starts a
|
||||
// new run. Requests above the configured body limit (8 MiB by default) answer 413 `payload_too_large`.
|
||||
// Semantic rules that the schema cannot express answer 400 `validation_failed`: group IDs are unique
|
||||
// in a run, test IDs are unique in a group, and the number of tests multiplied by
|
||||
// `limits.time_limit_ms` does not exceed 300000.
|
||||
//
|
||||
// PUT /v1/runs/{run_id}
|
||||
SubmitRun(ctx context.Context, req *RunRequest, params SubmitRunParams) (SubmitRunRes, error)
|
||||
// NewError creates *ProblemStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
NewError(ctx context.Context, err error) *ProblemStatusCode
|
||||
}
|
||||
|
||||
// Server implements http server based on OpenAPI v3 specification and
|
||||
// calls Handler to handle requests.
|
||||
type Server struct {
|
||||
h Handler
|
||||
sec SecurityHandler
|
||||
baseServer
|
||||
}
|
||||
|
||||
// NewServer creates new Server.
|
||||
func NewServer(h Handler, sec SecurityHandler, opts ...ServerOption) (*Server, error) {
|
||||
s, err := newServerConfig(opts...).baseServer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Server{
|
||||
h: h,
|
||||
sec: sec,
|
||||
baseServer: s,
|
||||
}, nil
|
||||
}
|
||||
Reference in new issue
Block a user