-
Notifications
You must be signed in to change notification settings - Fork 46
/
option.go
56 lines (48 loc) · 1.05 KB
/
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
package rabbitmqworker
type (
option struct {
consumerGroup string
exchangeName string
broker string // for log when startup
maxGoroutines int
debugMode bool
}
// OptionFunc type
OptionFunc func(*option)
)
func getDefaultOption() option {
return option{
maxGoroutines: 10,
debugMode: true,
}
}
// SetMaxGoroutines option func
func SetMaxGoroutines(maxGoroutines int) OptionFunc {
return func(o *option) {
o.maxGoroutines = maxGoroutines
}
}
// SetDebugMode option func
func SetDebugMode(debugMode bool) OptionFunc {
return func(o *option) {
o.debugMode = debugMode
}
}
// SetBrokerHost option func
func SetBrokerHost(broker string) OptionFunc {
return func(o *option) {
o.broker = broker
}
}
// SetConsumerGroup option func, for log when startup
func SetConsumerGroup(consumerGroup string) OptionFunc {
return func(o *option) {
o.consumerGroup = consumerGroup
}
}
// SetExchangeName option func
func SetExchangeName(exchangeName string) OptionFunc {
return func(o *option) {
o.exchangeName = exchangeName
}
}