feat: postpone sandbox grpc connection time
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
张泊明518370910136 2024-03-23 18:14:17 -04:00
parent f6cbfa7973
commit 2237ce41eb
GPG Key ID: D47306D7062CDA9D
2 changed files with 8 additions and 3 deletions

View File

@ -10,11 +10,15 @@ import (
) )
type Sandbox struct { type Sandbox struct {
execClient pb.ExecutorClient execServer, token string
cachedMap map[string]string cachedMap map[string]string
execClient pb.ExecutorClient
} }
func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) { func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
if e.execClient == nil {
e.execClient = createExecClient(e.execServer, e.token)
}
// cannot use range loop since we need to change the value // cannot use range loop since we need to change the value
for i := 0; i < len(cmds); i++ { for i := 0; i < len(cmds); i++ {
cmd := &cmds[i] cmd := &cmds[i]

View File

@ -9,7 +9,8 @@ var name = "sandbox"
func init() { func init() {
stage.RegisterExecutor(name, &Sandbox{ stage.RegisterExecutor(name, &Sandbox{
// TODO: read from conf // TODO: read from conf
execClient: createExecClient("localhost:5051", ""), execServer: "localhost:5051",
token: "",
cachedMap: make(map[string]string), cachedMap: make(map[string]string),
}) })
} }