wip: add analysis runner / agent, separate Server/Queue/Agent, use New* initializers
This commit is contained in:
committed by
=Michael Hohn
parent
2ab596bf1d
commit
f7155eba50
@@ -1,4 +1,14 @@
|
||||
package queue
|
||||
|
||||
import (
|
||||
"mrvacommander/pkg/common"
|
||||
"mrvacommander/pkg/storage"
|
||||
)
|
||||
|
||||
type Queue interface {
|
||||
Jobs() chan common.AnalyzeJob
|
||||
Results() chan common.AnalyzeResult
|
||||
StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation,
|
||||
session_id int,
|
||||
session_language string)
|
||||
}
|
||||
|
||||
@@ -6,13 +6,15 @@ import (
|
||||
"mrvacommander/pkg/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
NumWorkers int
|
||||
Jobs chan common.AnalyzeJob
|
||||
Results chan common.AnalyzeResult
|
||||
)
|
||||
func (q *QueueSingle) Jobs() chan common.AnalyzeJob {
|
||||
return q.jobs
|
||||
}
|
||||
|
||||
func StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation, session_id int,
|
||||
func (q *QueueSingle) Results() chan common.AnalyzeResult {
|
||||
return q.results
|
||||
}
|
||||
|
||||
func (q *QueueSingle) StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation, session_id int,
|
||||
session_language string) {
|
||||
slog.Debug("Queueing codeql database analyze jobs")
|
||||
|
||||
@@ -23,7 +25,7 @@ func StartAnalyses(analysis_repos *map[common.OwnerRepo]storage.DBLocation, sess
|
||||
|
||||
ORL: orl,
|
||||
}
|
||||
Jobs <- info
|
||||
q.jobs <- info
|
||||
storage.SetStatus(session_id, orl, common.StatusQueued)
|
||||
storage.AddJob(session_id, info)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
package queue
|
||||
|
||||
import "mrvacommander/pkg/common"
|
||||
|
||||
type QueueSingle struct {
|
||||
NumWorkers int
|
||||
jobs chan common.AnalyzeJob
|
||||
results chan common.AnalyzeResult
|
||||
}
|
||||
|
||||
func NewQueueSingle(numWorkers int) *QueueSingle {
|
||||
q := QueueSingle{}
|
||||
q.jobs = make(chan common.AnalyzeJob, 10)
|
||||
q.results = make(chan common.AnalyzeResult, 10)
|
||||
q.NumWorkers = numWorkers
|
||||
return &q
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user