-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
39 lines (31 loc) · 802 Bytes
/
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
package config
import (
"github.com/mustafaturan/bus/v3"
"github.com/mustafaturan/monoton/v3"
"github.com/mustafaturan/monoton/v3/sequencer"
)
// Bus is a ref to bus.Bus
var Bus *bus.Bus
// Monoton is an instance of monoton.Monoton
var Monoton monoton.Monoton
// Init inits the app config
func Init() {
// configure id generator (it doesn't have to be monoton)
node := uint64(1)
initialTime := uint64(1577865600000)
m, err := monoton.New(sequencer.NewMillisecond(), node, initialTime)
if err != nil {
panic(err)
}
// init an id generator
var idGenerator bus.Next = m.Next
// create a new bus instance
b, err := bus.NewBus(idGenerator)
if err != nil {
panic(err)
}
// maybe register topics in here
b.RegisterTopics("order.created", "order.canceled")
Bus = b
Monoton = m
}