update: dependencies

This commit is contained in:
Oarkflow
2025-02-17 20:39:57 +05:45
parent fe9d9d0dc5
commit dbd1cfa23f
17 changed files with 142 additions and 2183 deletions

View File

@@ -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