-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
44 lines (37 loc) · 902 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
44
package profiler
import (
"os"
"time"
)
// Option is a Profiler functional option
type Option func(*Profiler)
// WithSignal sets the signal to activate the pprof handler
func WithSignal(s os.Signal) Option {
return func(p *Profiler) {
p.signal = s
}
}
// WithAddress sets the listen address of the pprof handler
func WithAddress(address string) Option {
return func(p *Profiler) {
p.address = address
}
}
// WithTimeout sets the timeout after the pprof handler will be shutdown
func WithTimeout(timeout time.Duration) Option {
return func(p *Profiler) {
p.timeout = timeout
}
}
// WithEventHandler registers a custom event handler
func WithEventHandler(evt EventHandler) Option {
return func(p *Profiler) {
p.evt = evt
}
}
// WithHooks registers the Profiler hooks
func WithHooks(hooks ...Hooker) Option {
return func(p *Profiler) {
p.hooks = append(p.hooks, hooks...)
}
}