Combine New/Setup functions
This commit is contained in:
committed by
=Michael Hohn
parent
f611f02d1c
commit
cd0647836e
@@ -24,8 +24,8 @@ type RunnerSingle struct {
|
||||
queue queue.Queue
|
||||
}
|
||||
|
||||
func NewAgentSingle(numWorkers int, queue queue.Queue) *RunnerSingle {
|
||||
r := RunnerSingle{queue: queue}
|
||||
func NewAgentSingle(numWorkers int, av *Visibles) *RunnerSingle {
|
||||
r := RunnerSingle{queue: av.Queue}
|
||||
|
||||
for id := 1; id <= numWorkers; id++ {
|
||||
go r.worker(id)
|
||||
@@ -42,10 +42,6 @@ type Visibles struct {
|
||||
QLDBStore storage.Storage
|
||||
}
|
||||
|
||||
func (c *RunnerSingle) Setup(st *Visibles) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r *RunnerSingle) worker(wid int) {
|
||||
var job common.AnalyzeJob
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@ type LoggerSingle struct {
|
||||
modules *Visibles
|
||||
}
|
||||
|
||||
func NewLoggerSingle() *LoggerSingle {
|
||||
func NewLoggerSingle(v *Visibles) *LoggerSingle {
|
||||
l := LoggerSingle{}
|
||||
|
||||
l.modules = v
|
||||
return &l
|
||||
}
|
||||
|
||||
type Visibles struct{}
|
||||
|
||||
func (l *LoggerSingle) Setup(v *Visibles) {
|
||||
l.modules = v
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@ type Visibles struct {
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
func (q *QueueSingle) Setup(v *Visibles) {
|
||||
q.modules = v
|
||||
}
|
||||
|
||||
func NewQueueSingle(numWorkers int) *QueueSingle {
|
||||
func NewQueueSingle(numWorkers int, v *Visibles) *QueueSingle {
|
||||
q := QueueSingle{}
|
||||
q.jobs = make(chan common.AnalyzeJob, 10)
|
||||
q.results = make(chan common.AnalyzeResult, 10)
|
||||
q.NumWorkers = numWorkers
|
||||
|
||||
q.modules = v
|
||||
|
||||
return &q
|
||||
}
|
||||
|
||||
@@ -21,11 +21,6 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func (c *CommanderSingle) Setup(st *Visibles) {
|
||||
c.st = st
|
||||
setupEndpoints(c)
|
||||
}
|
||||
|
||||
func setupEndpoints(c CommanderAPI) {
|
||||
r := mux.NewRouter()
|
||||
|
||||
|
||||
@@ -29,8 +29,12 @@ type CommanderSingle struct {
|
||||
st *Visibles
|
||||
}
|
||||
|
||||
func NewCommanderSingle() *CommanderSingle {
|
||||
func NewCommanderSingle(st *Visibles) *CommanderSingle {
|
||||
c := CommanderSingle{}
|
||||
|
||||
c.st = st
|
||||
setupEndpoints(&c)
|
||||
|
||||
return &c
|
||||
}
|
||||
|
||||
@@ -38,8 +42,12 @@ type CommanderContainer struct {
|
||||
st *Visibles
|
||||
}
|
||||
|
||||
func NewCommanderContainer() *CommanderContainer {
|
||||
func NewCommanderContainer(st *Visibles) *CommanderContainer {
|
||||
c := CommanderContainer{}
|
||||
|
||||
c.st = st
|
||||
setupEndpoints(&c)
|
||||
|
||||
return &c
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,7 @@ func (s *StorageContainer) FindAvailableDBs(analysisReposRequested []common.Owne
|
||||
return notFoundRepos, analysisRepos
|
||||
}
|
||||
|
||||
func (s *StorageContainer) Setup(v *Visibles) {
|
||||
// TODO XX: set up qldb_db
|
||||
s.modules = v
|
||||
|
||||
}
|
||||
|
||||
func NewQLDBStore(startingID int) (*StorageContainer, error) {
|
||||
func NewQLDBStore(startingID int, v *Visibles) (*StorageContainer, error) {
|
||||
// TODO drop the startingID
|
||||
db, err := ConnectDB(DBSpec{
|
||||
Host: "postgres",
|
||||
@@ -61,10 +55,13 @@ func NewQLDBStore(startingID int) (*StorageContainer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO XX: set up qldb_db
|
||||
s.modules = v
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
func NewServerStore(startingID int) (*StorageContainer, error) {
|
||||
func NewServerStore(startingID int, v *Visibles) (*StorageContainer, error) {
|
||||
db, err := ConnectDB(DBSpec{
|
||||
Host: "postgres",
|
||||
Port: 5432,
|
||||
@@ -85,6 +82,9 @@ func NewServerStore(startingID int) (*StorageContainer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO XX: set up qldb_db
|
||||
s.modules = v
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -23,13 +23,12 @@ var (
|
||||
mutex sync.Mutex
|
||||
)
|
||||
|
||||
func NewStorageSingle(startingID int) *StorageSingle {
|
||||
func NewStorageSingle(startingID int, v *Visibles) *StorageSingle {
|
||||
s := StorageSingle{currentID: startingID}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *StorageSingle) Setup(v *Visibles) {
|
||||
s.modules = v
|
||||
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *StorageSingle) NextID() int {
|
||||
|
||||
Reference in New Issue
Block a user