feat(practice): add the code runner port and its TLS client

This commit is contained in:
shira committed 2026-10-11 09:48:44 +03:00
1 parent 53a125f2b5
commit facc1789b1
24 files changed
+3374 -6

No files matched your search

@@ -0,0 +1,39 @@
// Package disabled provides the code runner for an unset CODE_RUNNER_URL.
package disabled
import (
"context"
"fmt"
"lincodex/backend/internal/port/outbound"
)
// Runner runs nothing. Every valid request is reported as
// outbound.ErrCodeRunnerDisabled, never as a verdict, so a caller cannot grade
// a submission while the practice runner is off.
type Runner struct{}
var _ outbound.CodeRunner = (*Runner)(nil)
func NewRunner() *Runner {
return &Runner{}
}
// Submit validates the request first so that local runs without a runner
// still expose invalid task content, then reports the runner as disabled. It
// logs nothing and keeps no copy of the source or the tests.
func (runner *Runner) Submit(_ context.Context, request outbound.CodeRunRequest) (outbound.CodeRunStatus, error) {
return outbound.CodeRunStatus{}, refuse("Runner.Submit", request)
}
// Poll behaves like Submit.
func (runner *Runner) Poll(_ context.Context, request outbound.CodeRunRequest) (outbound.CodeRunStatus, error) {
return outbound.CodeRunStatus{}, refuse("Runner.Poll", request)
}
func refuse(location string, request outbound.CodeRunRequest) error {
if err := request.Validate(); err != nil {
return fmt.Errorf("%s - validate request: %w", location, err)
}
return fmt.Errorf("%s - CODE_RUNNER_URL is not set: %w", location, outbound.ErrCodeRunnerDisabled)
}