feat: sig

This commit is contained in:
sujit
2025-03-29 19:06:28 +05:45
parent e8c503a488
commit 0205cf35ef
2 changed files with 28 additions and 5 deletions

View File

@@ -130,6 +130,8 @@ func defaultOptions() *Options {
maxMemoryLoad: 5000000,
storage: NewMemoryTaskStorage(10 * time.Minute),
logger: logger.NewDefaultLogger(),
BrokerRateLimiter: NewRateLimiter(10, 5),
ConsumerRateLimiter: NewRateLimiter(10, 5),
}
}
@@ -254,3 +256,27 @@ func WithJitterPercent(val float64) Option {
opts.jitterPercent = val
}
}
func WithBrokerRateLimiter(rate int, burst int) Option {
return func(opts *Options) {
opts.BrokerRateLimiter = NewRateLimiter(rate, burst)
}
}
func WithConsumerRateLimiter(rate int, burst int) Option {
return func(opts *Options) {
opts.ConsumerRateLimiter = NewRateLimiter(rate, burst)
}
}
func DisableBrokerRateLimit() Option {
return func(opts *Options) {
opts.BrokerRateLimiter = nil
}
}
func DisableConsumerRateLimit() Option {
return func(opts *Options) {
opts.ConsumerRateLimiter = nil
}
}