/
dtf_options.go
60 lines (49 loc) · 1.51 KB
/
dtf_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package dtf
import (
"time"
"github.com/danenmao/pterergate-dtf/dtf/dtfdef"
"github.com/danenmao/pterergate-dtf/dtf/extconfig"
"github.com/danenmao/pterergate-dtf/dtf/taskmodel"
)
// 用于设置服务配置
type ServiceOption func(config *dtfdef.ServiceConfig)
func WithPrestop(d time.Duration) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.PrestopDuration = d
}
}
func WithMySQL(mysql *extconfig.MySQLAddress) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.MySQLServer = *mysql
}
}
func WithRedis(redis *extconfig.RedisAddress) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.RedisServer = *redis
}
}
func WithMongoDB(mongo *extconfig.MongoAddress) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.MongoServer = *mongo
}
}
func WithExecutor(executor taskmodel.ExecutorInvoker) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.ExecutorService = executor
}
}
func WithCollector(collector taskmodel.CollectorInvoker) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.CollectorService = collector
}
}
func WithRegisterExecutorHandler(register taskmodel.RegisterExecutorRequestHandler) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.ExecutorHandlerRegister = register
}
}
func WithRegisterCollectorHandler(register taskmodel.RegisterCollectorRequestHandler) ServiceOption {
return func(config *dtfdef.ServiceConfig) {
config.CollectorHandlerRegister = register
}
}