forked from rambler-digital-solutions/thrustmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (29 loc) · 911 Bytes
/
main.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
package exhaust
import (
"fmt"
"github.com/rambler-digital-solutions/thrustmq/common"
"github.com/rambler-digital-solutions/thrustmq/config"
"net"
)
var (
TurbineChannel = make(chan common.IndexRecord, config.Config.Exhaust.TurbineBuffer)
CombustorChannel common.MessageChannel = make(common.MessageChannel, config.Config.Exhaust.CombustionBuffer)
ConnectionsMap common.ConnectionsMap = make(common.ConnectionsMap)
topicsMap common.TopicsMap = make(common.TopicsMap)
State StateStruct = loadState()
)
func Init() {
fmt.Printf("Spinning turbine on port %d\n", config.Config.Exhaust.Port)
go saveState()
socket, err := net.Listen("tcp", fmt.Sprintf(":%d", config.Config.Exhaust.Port))
common.FaceIt(err)
go combustion()
go turbine()
var (
connection net.Conn
)
for {
connection, _ = socket.Accept()
go blow(connection)
}
}