Add timeout and retry interval to GetRunner api
This commit is contained in:
@@ -19,46 +19,6 @@ import (
|
||||
|
||||
var log = logging.MustGetLogger("cursorius-server")
|
||||
|
||||
type RunnerManagerChans struct {
|
||||
Allocation chan RunnerAllocationRequest
|
||||
Release chan RunnerReleaseRequest
|
||||
Registration chan RunnerRegistrationRequest
|
||||
}
|
||||
|
||||
type runnerManager struct {
|
||||
chans RunnerManagerChans
|
||||
connectedRunners []Runner
|
||||
numConnectedRunners uint64
|
||||
configuredRunners map[string]config.Runner
|
||||
db database.Database
|
||||
}
|
||||
|
||||
type RunnerAllocationRequest struct {
|
||||
Tags []string
|
||||
RespChan chan RunnerAllocationResponse
|
||||
}
|
||||
|
||||
type RunnerAllocationResponse struct {
|
||||
Runner *Runner
|
||||
Err error
|
||||
}
|
||||
|
||||
type RunnerReleaseRequest struct {
|
||||
Runner *Runner
|
||||
}
|
||||
|
||||
type RunnerRegistrationRequest struct {
|
||||
Secret string
|
||||
Id string
|
||||
Tags []string
|
||||
conn *websocket.Conn
|
||||
}
|
||||
|
||||
type runnerJob struct {
|
||||
Id string
|
||||
URL string
|
||||
}
|
||||
|
||||
func (r *runnerManager) processRunnerAllocation(req RunnerAllocationRequest) {
|
||||
tagsStr := util.FormatTags(req.Tags)
|
||||
log.Infof("Got request for runner with tags \"%v\"", tagsStr)
|
||||
@@ -92,6 +52,7 @@ runnerIter:
|
||||
|
||||
runnersToRemove = append(runnersToRemove, i)
|
||||
foundRunner = true
|
||||
log.Debugf("Runner %v has requested tags, allocating", runner.id)
|
||||
req.RespChan <- RunnerAllocationResponse{
|
||||
Runner: &r.connectedRunners[i],
|
||||
Err: nil,
|
||||
@@ -103,7 +64,7 @@ runnerIter:
|
||||
// since we iterate, all the indexes will be in accending order
|
||||
for i, runnerInd := range runnersToRemove {
|
||||
r.connectedRunners[runnerInd-i] = r.connectedRunners[len(r.connectedRunners)-1]
|
||||
r.connectedRunners = r.connectedRunners[0 : len(r.connectedRunners)-2]
|
||||
r.connectedRunners = r.connectedRunners[0 : len(r.connectedRunners)-1]
|
||||
}
|
||||
|
||||
if foundRunner {
|
||||
@@ -115,7 +76,7 @@ runnerIter:
|
||||
errorMsg = "no connected runners"
|
||||
}
|
||||
req.RespChan <- RunnerAllocationResponse{
|
||||
Runner: &Runner{},
|
||||
Runner: nil,
|
||||
Err: fmt.Errorf("Could not allocate runner: %v", errorMsg),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user