-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
43 lines (34 loc) · 900 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package interval
import (
nc "github.com/geniusrabbit/notificationcenter/v2"
)
type handler func() any
// Options time interval wrapper
type Options struct {
// Handler generates message by time interval
Handler handler
// ErrorHandler of message processing
ErrorHandler nc.ErrorHandler
// PanicHandler process panic
PanicHandler nc.PanicHandler
}
// Option func type
type Option func(opt *Options)
// WithHandler set custom message generation function
func WithHandler(h handler) Option {
return func(options *Options) {
options.Handler = h
}
}
// WithErrorHandler set handler of error processing
func WithErrorHandler(h nc.ErrorHandler) Option {
return func(options *Options) {
options.ErrorHandler = h
}
}
// WithPanicHandler set handler of panic processing
func WithPanicHandler(h nc.PanicHandler) Option {
return func(options *Options) {
options.PanicHandler = h
}
}