frontend: only pass runner to MakeFrontend, add Runner.GetSubmitQueue()

This commit is contained in:
Florian Klink 2019-11-25 17:35:11 +01:00
parent fecbf8b3e2
commit 40b2f11543
3 changed files with 9 additions and 2 deletions

View file

@ -42,9 +42,11 @@ func loadTemplate(templateName string, funcMap template.FuncMap) (*template.Temp
}
// MakeFrontend configures the router and returns a new Frontend struct
func MakeFrontend(runner *submitqueue.Runner, submitQueue *submitqueue.SubmitQueue) *Frontend {
func MakeFrontend(runner *submitqueue.Runner) *Frontend {
router := gin.Default()
submitQueue := runner.GetSubmitQueue()
funcMap := template.FuncMap{
"isAutoSubmittable": func(serie *submitqueue.Serie) bool {
return submitQueue.IsAutoSubmittable(serie)

View file

@ -91,7 +91,7 @@ func main() {
submitQueue := submitqueue.MakeSubmitQueue(gerritClient, projectName, branchName, submitQueueTag)
runner := submitqueue.NewRunner(submitQueue)
handler := frontend.MakeFrontend(runner, submitQueue)
handler := frontend.MakeFrontend(runner)
// fetch only on first run
runner.Trigger(true)

View file

@ -28,6 +28,11 @@ func (r *Runner) GetResults() (*time.Time, []*Result) {
return r.currentlyRunning, r.results
}
// GetSubmitQueue returns the submit queue object, to be consumed by the frontend
func (r *Runner) GetSubmitQueue() (*SubmitQueue) {
return r.SubmitQueue
}
// Trigger starts a new batch job
// TODO: make sure only one batch job is started at the same time
// if a batch job is already started, ignore the newest request