File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package WorkQueue
22
33import (
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+
6063func (j JobDispatcher ) dispatch () {
6164 go func () {
6265 for {
Original file line number Diff line number Diff line change 11package WorkQueue
22
3- import cn "github.com/Zondax/zindexer/connections"
4-
53type 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
1614type Work struct {
1715 JobId int64
You can’t perform that action at this time.
0 commit comments