JOJ3/internal/executor/sandbox/meta.go
张泊明518370910136 73b66e40e5
All checks were successful
build / build (push) Successful in 1m22s
build / trigger-build-image (push) Has been skipped
fix: derive sandbox RPC deadline from command limits
2026-08-02 01:05:57 -07:00

42 lines
1000 B
Go

// Package sandbox provides a sandboxed execution environment for running
// untrusted code. It integrates with the go-judge execution service to provide
// isolated and secure code execution. By default, it uses gRPC to communicate
// with go-judge.
package sandbox
import (
"time"
"github.com/criyle/go-judge/pb"
"github.com/joint-online-judge/JOJ3/internal/stage"
"google.golang.org/grpc"
)
var name = "sandbox"
type Sandbox struct {
execServer, token string
cachedMap map[string]string
execClient pb.ExecutorClient
conn *grpc.ClientConn
}
const rpcTimeoutMargin = 30 * time.Second
func init() {
stage.RegisterExecutor(name, &Sandbox{
execServer: "localhost:5051",
token: "",
cachedMap: make(map[string]string),
})
}
// overwrite the default registered executor
func InitWithConf(execServer, token string) {
stage.RegisterExecutor(name, &Sandbox{
execServer: execServer,
token: token,
cachedMap: make(map[string]string),
})
}