-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
49 lines (44 loc) · 1.17 KB
/
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
package ctrl
import (
"fmt"
"time"
"github.com/metal-toolbox/rivets/v2/events"
)
const (
subjectPrefix = "com.hollow.sh.controllers.commands"
)
func queueConfig(appName, facilityCode, subjectSuffix, natsURL, credsFile string) events.NatsOptions {
// com.hollow.sh.controllers.commands.sandbox.servers.firmwareInstall
consumerSubject := fmt.Sprintf(
"%s.%s.servers.%s",
subjectPrefix,
facilityCode,
subjectSuffix,
)
return events.NatsOptions{
URL: natsURL,
AppName: appName,
CredsFile: credsFile,
ConnectTimeout: time.Second * 60,
Stream: &events.NatsStreamOptions{
Name: "controllers",
Subjects: []string{
// com.hollow.sh.controllers.commands.>
subjectPrefix + ".>",
},
Acknowledgements: true,
DuplicateWindow: time.Minute * 5,
Retention: "workQueue",
},
Consumer: &events.NatsConsumerOptions{
Pull: true,
AckWait: time.Minute * 5,
MaxAckPending: 10,
Name: fmt.Sprintf("%s-%s", facilityCode, appName),
QueueGroup: appName,
FilterSubject: consumerSubject,
SubscribeSubjects: []string{consumerSubject},
},
KVReplicationFactor: 3,
}
}