diff options
author | Valery Piashchynski <[email protected]> | 2021-09-01 13:19:09 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-09-01 13:19:09 +0300 |
commit | 9c8da162b3347b632f33f85d56e8c1ff7014631a (patch) | |
tree | bb614a186e05adf816b3f2b62e2d25bfa821a574 /plugins/boltdb/boltjobs | |
parent | 0437d1f58514f694ea86e8176e621c009cd510f9 (diff) |
Code polishing before release
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/boltdb/boltjobs')
-rw-r--r-- | plugins/boltdb/boltjobs/consumer.go | 2 | ||||
-rw-r--r-- | plugins/boltdb/boltjobs/listener.go | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/plugins/boltdb/boltjobs/consumer.go b/plugins/boltdb/boltjobs/consumer.go index ed0eda61..46d596fa 100644 --- a/plugins/boltdb/boltjobs/consumer.go +++ b/plugins/boltdb/boltjobs/consumer.go @@ -222,7 +222,7 @@ func FromPipeline(pipeline *pipeline.Pipeline, log logger.Logger, cfg config.Con return &consumer{ file: pipeline.String(file, rrDB), priority: pipeline.Int(priority, 10), - prefetch: pipeline.Int(prefetch, 100), + prefetch: pipeline.Int(prefetch, 1000), permissions: conf.Permissions, bPool: sync.Pool{New: func() interface{} { diff --git a/plugins/boltdb/boltjobs/listener.go b/plugins/boltdb/boltjobs/listener.go index 7c161555..081d3f57 100644 --- a/plugins/boltdb/boltjobs/listener.go +++ b/plugins/boltdb/boltjobs/listener.go @@ -3,6 +3,7 @@ package boltjobs import ( "bytes" "encoding/gob" + "sync/atomic" "time" "github.com/spiral/roadrunner/v2/utils" @@ -18,6 +19,10 @@ func (c *consumer) listener() { c.log.Info("boltdb listener stopped") return case <-tt.C: + if atomic.LoadUint64(c.active) > uint64(c.prefetch) { + time.Sleep(time.Second) + continue + } tx, err := c.db.Begin(true) if err != nil { c.log.Error("failed to begin writable transaction, job will be read on the next attempt", "error", err) |