优化集群定时器的逻辑

This commit is contained in:
Yun
2024-04-04 10:58:57 +08:00
parent 43d2798b41
commit 4d07ce2c09
6 changed files with 234 additions and 49 deletions
+27
View File
@@ -0,0 +1,27 @@
package timerx
type Options struct {
logger Logger
}
func defaultOptions() Options {
return Options{
logger: NewLogger(),
}
}
type Option func(*Options)
func newOptions(opts ...Option) Options {
o := defaultOptions()
for _, opt := range opts {
opt(&o)
}
return o
}
func SetLogger(log Logger) Option {
return func(o *Options) {
o.logger = log
}
}