forked from gotomicro/ego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ego_option.go
72 lines (61 loc) · 1.68 KB
/
ego_option.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package ego
import (
"os"
"time"
)
// Option overrides a Container's default configuration.
type Option func(a *Ego)
// WithHang 是否允许系统悬挂起来,0 表示不悬挂, 1 表示悬挂。目的是一些脚本操作的时候,不想主线程停止
func WithHang(flag bool) Option {
return func(a *Ego) {
a.opts.hang = flag
}
}
// WithDisableBanner 禁止banner
func WithDisableBanner(disableBanner bool) Option {
return func(a *Ego) {
a.opts.disableBanner = disableBanner
}
}
// WithArguments 传入arguments
func WithArguments(arguments []string) Option {
return func(a *Ego) {
a.opts.arguments = arguments
}
}
// WithDisableFlagConfig 禁止config
func WithDisableFlagConfig(disableFlagConfig bool) Option {
return func(a *Ego) {
a.opts.disableFlagConfig = disableFlagConfig
}
}
// WithConfigPrefix 设置配置前缀
func WithConfigPrefix(configPrefix string) Option {
return func(a *Ego) {
a.opts.configPrefix = configPrefix
}
}
// WithBeforeStopClean 设置运行前清理
func WithBeforeStopClean(fns ...func() error) Option {
return func(a *Ego) {
a.opts.beforeStopClean = append(a.opts.beforeStopClean, fns...)
}
}
// WithAfterStopClean 设置运行后清理
func WithAfterStopClean(fns ...func() error) Option {
return func(a *Ego) {
a.opts.afterStopClean = append(a.opts.afterStopClean, fns...)
}
}
// WithStopTimeout 设置停止的超时时间
func WithStopTimeout(timeout time.Duration) Option {
return func(e *Ego) {
e.opts.stopTimeout = timeout
}
}
// WithShutdownSignal 设置停止信号量
func WithShutdownSignal(signals ...os.Signal) Option {
return func(e *Ego) {
e.opts.shutdownSignals = append(e.opts.shutdownSignals, signals...)
}
}