JOJ3/internal/executor/sandbox/meta.go
张泊明518370910136 1fbc37d669
All checks were successful
submodules sync / sync (push) Successful in 59s
build / build (push) Successful in 2m16s
build / trigger-build-image (push) Successful in 6s
fix: better stage reliability (#103)
Reviewed-on: #103
Co-authored-by: Boming Zhang <bomingzh@sjtu.edu.cn>
Co-committed-by: Boming Zhang <bomingzh@sjtu.edu.cn>
2026-08-03 10:37:40 +08: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),
})
}