feat: read sandbox conf
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
张泊明518370910136 2024-06-30 02:42:51 -04:00
parent 2f8604f647
commit b608a22cfd
GPG Key ID: D47306D7062CDA9D
4 changed files with 22 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import (
)
type Conf struct {
SandboxExecServer string `default:"localhost:5051"`
SandboxToken string `default:""`
LogLevel int `default:"0"`
OutputPath string `default:"joj3_result.json"`
Stages []struct {

View File

@ -5,7 +5,7 @@ import (
"log/slog"
"os"
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors"
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
@ -77,6 +77,7 @@ func main() {
os.Exit(1)
}
setupSlog(conf)
executors.InitWithConf(conf.SandboxExecServer, conf.SandboxToken)
stages := generateStages(conf)
defer stage.Cleanup()
results := stage.Run(stages)

View File

@ -2,8 +2,13 @@ package executors
import (
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/dummy"
_ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/sandbox"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/sandbox"
)
// this file does nothing but imports to ensure all the init() functions
// in the subpackages are called
// overwrite the default registered executors
func InitWithConf(sandboxExecServer, sandboxToken string) {
sandbox.InitWithConf(sandboxExecServer, sandboxToken)
}

View File

@ -8,9 +8,17 @@ var name = "sandbox"
func init() {
stage.RegisterExecutor(name, &Sandbox{
// TODO: read from conf
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),
})
}