Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions core/services/run_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package services
import (
"fmt"
"sync"
"time"

"chainlink/core/logger"
"chainlink/core/store/models"
Expand Down Expand Up @@ -40,45 +39,23 @@ type runQueue struct {
workersWg sync.WaitGroup

runExecutor RunExecutor

runsQueued uint
runsExecuted uint
quit chan struct{}
}

// NewRunQueue initializes a RunQueue.
func NewRunQueue(runExecutor RunExecutor) RunQueue {
return &runQueue{
quit: make(chan struct{}),
workers: make(map[string]int),
runExecutor: runExecutor,
}
}

// Start prepares the job runner for accepting runs to execute.
func (rq *runQueue) Start() error {
go rq.statisticsLogger()
return nil
}

func (rq *runQueue) statisticsLogger() {
ticker := time.NewTicker(5 * time.Minute)
for {
select {
case <-ticker.C:
rq.workersMutex.RLock()
logger.Debugw("Run queue statistics", "runs_executed", rq.runsExecuted, "runs_queued", rq.runsQueued, "worker_count", len(rq.workers))
rq.workersMutex.RUnlock()
case <-rq.quit:
ticker.Stop()
return
}
}
}

// Stop closes all open worker channels.
func (rq *runQueue) Stop() {
rq.quit <- struct{}{}
rq.workersWg.Wait()
}

Expand All @@ -90,12 +67,10 @@ func (rq *runQueue) Run(run *models.JobRun) {

rq.workersMutex.Lock()
if queueCount, present := rq.workers[runID]; present {
rq.runsQueued += 1
rq.workers[runID] = queueCount + 1
rq.workersMutex.Unlock()
return
}
rq.runsExecuted += 1
rq.workers[runID] = 1
numberRunQueueWorkers.Set(float64(len(rq.workers)))
rq.workersMutex.Unlock()
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ require (
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/client_model v0.0.0-20191202183732-d1d2010b5bee // indirect
github.com/prometheus/procfs v0.0.8 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.6.0 // indirect
github.com/satori/go.uuid v1.2.0
Expand Down