mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 07:57:00 +08:00
update: dependencies
This commit is contained in:
15
options.go
15
options.go
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/oarkflow/mq/logger"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@@ -128,6 +129,7 @@ type Options struct {
|
||||
cleanTaskOnComplete bool
|
||||
enableWorkerPool bool
|
||||
respondPendingResult bool
|
||||
logger logger.Logger
|
||||
}
|
||||
|
||||
func (o *Options) SetSyncMode(sync bool) {
|
||||
@@ -138,6 +140,10 @@ func (o *Options) NumOfWorkers() int {
|
||||
return o.numOfWorkers
|
||||
}
|
||||
|
||||
func (o *Options) Logger() logger.Logger {
|
||||
return o.logger
|
||||
}
|
||||
|
||||
func (o *Options) Storage() TaskStorage {
|
||||
return o.storage
|
||||
}
|
||||
@@ -156,7 +162,7 @@ func (o *Options) MaxMemoryLoad() int64 {
|
||||
|
||||
func defaultOptions() *Options {
|
||||
return &Options{
|
||||
brokerAddr: ":8080",
|
||||
brokerAddr: ":8081",
|
||||
maxRetries: 5,
|
||||
respondPendingResult: true,
|
||||
initialDelay: 2 * time.Second,
|
||||
@@ -166,6 +172,7 @@ func defaultOptions() *Options {
|
||||
numOfWorkers: runtime.NumCPU(),
|
||||
maxMemoryLoad: 5000000,
|
||||
storage: NewMemoryTaskStorage(10 * time.Minute),
|
||||
logger: logger.NewDefaultLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +193,12 @@ func WithNotifyResponse(callback Callback) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogger(log logger.Logger) Option {
|
||||
return func(opts *Options) {
|
||||
opts.logger = log
|
||||
}
|
||||
}
|
||||
|
||||
func WithWorkerPool(queueSize, numOfWorkers int, maxMemoryLoad int64) Option {
|
||||
return func(opts *Options) {
|
||||
opts.enableWorkerPool = true
|
||||
|
Reference in New Issue
Block a user