Only initial MaxConcurrentIOSPushes once. (#591)

This commit is contained in:
Bo-Yi Wu
2021-07-16 16:30:01 +08:00
committed by GitHub
parent ab8b1991ab
commit 73ff554b19
13 changed files with 106 additions and 107 deletions

View File

@@ -3,20 +3,18 @@ package simple
import (
"errors"
"github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/gorush"
)
// Worker for simple queue using channel
type Worker struct {
cfg config.ConfYaml
queueNotification chan gorush.PushNotification
}
// Run start the worker
func (s *Worker) Run(_ chan struct{}) {
for notification := range s.queueNotification {
gorush.SendNotification(s.cfg, notification)
gorush.SendNotification(notification)
}
}
@@ -45,15 +43,9 @@ func (s *Worker) Enqueue(job interface{}) error {
}
}
// Config update current config
func (s *Worker) Config(cfg config.ConfYaml) {
s.cfg = cfg
}
// NewWorker for struct
func NewWorker(cfg config.ConfYaml) *Worker {
func NewWorker(num int) *Worker {
return &Worker{
cfg: cfg,
queueNotification: make(chan gorush.PushNotification, cfg.Core.QueueNum),
queueNotification: make(chan gorush.PushNotification, num),
}
}