-
Notifications
You must be signed in to change notification settings - Fork 224
/
rabbit_config.go
58 lines (44 loc) · 1.11 KB
/
rabbit_config.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
package ocrworker
import (
"flag"
)
type RabbitConfig struct {
AmqpURI string
Exchange string
ExchangeType string
RoutingKey string
Reliable bool
}
func DefaultTestConfig() RabbitConfig {
// Reliable: false due to major issues that would completely
// wedge the rpc worker. Setting the buffered channels length
// higher would delay the problem, but then it would still happen later.
rabbitConfig := RabbitConfig{
AmqpURI: "amqp://guest:guest@localhost:5672/",
Exchange: "open-ocr-exchange",
ExchangeType: "direct",
RoutingKey: "decode-ocr",
Reliable: false, // setting to false because of observed issues
}
return rabbitConfig
}
type FlagFunction func()
func NoOpFlagFunction() FlagFunction {
return func() {}
}
func DefaultConfigFlagsOverride(flagFunction FlagFunction) RabbitConfig {
rabbitConfig := DefaultTestConfig()
flagFunction()
var AmqpURI string
flag.StringVar(
&AmqpURI,
"amqp_uri",
"",
"The Amqp URI, eg: amqp://guest:guest@localhost:5672/",
)
flag.Parse()
if len(AmqpURI) > 0 {
rabbitConfig.AmqpURI = AmqpURI
}
return rabbitConfig
}