Skip to content

Commit 310a7eb

Browse files
committed
Minor improvements on queued worker
1 parent 0c4ba6b commit 310a7eb

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

workers/workQueue/dispatcher.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package WorkQueue
22

33
import (
44
"fmt"
5-
"github.com/Zondax/zindexer/connections"
65
"go.uber.org/zap"
76
"time"
87
)
@@ -34,10 +33,10 @@ func NewJobDispatcher(cfg DispatcherConfig) JobDispatcher {
3433
return d
3534
}
3635

37-
func (j JobDispatcher) BuildWorkers(count int, dataSource connections.DataSource, constructor WorkerConstructor) {
36+
func (j JobDispatcher) BuildWorkers(count int, constructor WorkerConstructor) {
3837
for i := 0; i < count; i++ {
3938
workerId := fmt.Sprintf("worker.%d", i)
40-
worker := constructor(workerId, dataSource, j.workerChannel)
39+
worker := constructor(workerId, j.workerChannel)
4140
worker.Worker.Start()
4241
}
4342
}
@@ -57,6 +56,10 @@ func (j JobDispatcher) Start() {
5756
}
5857
}
5958

59+
func (j JobDispatcher) EnqueueWork(w Work) {
60+
j.jobPool.EnqueueJob(w)
61+
}
62+
6063
func (j JobDispatcher) dispatch() {
6164
go func() {
6265
for {

workers/workQueue/worker_queued.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package WorkQueue
22

3-
import cn "github.com/Zondax/zindexer/connections"
4-
53
type IQueuedWorker interface {
64
Start()
75
DoWork(Work)
@@ -11,7 +9,7 @@ type QueuedWorker struct {
119
Worker IQueuedWorker
1210
}
1311

14-
type WorkerConstructor func(string, cn.DataSource, chan chan Work) QueuedWorker
12+
type WorkerConstructor func(string, chan chan Work) QueuedWorker
1513

1614
type Work struct {
1715
JobId int64

0 commit comments

Comments
 (0)