test
This commit is contained in:
parent
21520b0253
commit
480fe508be
16
workers.go
16
workers.go
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
||||||
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
var x ChatWarsMessage
|
var x ChatWarsMessage
|
||||||
conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue)
|
conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue)
|
||||||
failOnError(err, "MQGetMsgWorker["+strconv.Itoa(id)+"] : Failed to connect to RabbitMQ")
|
failOnError(err, "MQGetMsgWorker["+strconv.Itoa(id)+"] : Failed to connect to RabbitMQ")
|
||||||
@ -58,7 +58,7 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
|
func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
|
||||||
log.Printf("SQLCWMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("SQLCWMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
for m := range msgs {
|
for m := range msgs {
|
||||||
objId, err := addObjMsg(m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
|
objId, err := addObjMsg(m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
|
||||||
logOnError(err, "SQLCWMsgWorker["+strconv.Itoa(id)+"] : Inserting message.")
|
logOnError(err, "SQLCWMsgWorker["+strconv.Itoa(id)+"] : Inserting message.")
|
||||||
@ -74,7 +74,7 @@ func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
|
|||||||
|
|
||||||
func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||||
var i int
|
var i int
|
||||||
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
for objId := range objIds {
|
for objId := range objIds {
|
||||||
m, err := getMsg(objId)
|
m, err := getMsg(objId)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
||||||
@ -256,7 +256,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SQLJobWorker(id int) {
|
func SQLJobWorker(id int) {
|
||||||
log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
for true {
|
for true {
|
||||||
jobs, err := loadCurrentJobs()
|
jobs, err := loadCurrentJobs()
|
||||||
logOnError(err, "SQLJobWorker["+strconv.Itoa(id)+"] : loadCurrentJobs")
|
logOnError(err, "SQLJobWorker["+strconv.Itoa(id)+"] : loadCurrentJobs")
|
||||||
@ -283,7 +283,7 @@ func SQLJobWorker(id int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
|
func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
|
||||||
log.Printf("TGCmdWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("TGCmdWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
for c := range cmds {
|
for c := range cmds {
|
||||||
j, err := json.Marshal(c)
|
j, err := json.Marshal(c)
|
||||||
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
||||||
@ -322,7 +322,7 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
||||||
log.Printf("MQTGCmdWorker[" + strconv.Itoa(id) + "] : Starting.")
|
//log.Printf("MQTGCmdWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||||
for c := range cmds {
|
for c := range cmds {
|
||||||
if _, ok := clientsKeepAlive[c.FromUserID64]; ok {
|
if _, ok := clientsKeepAlive[c.FromUserID64]; ok {
|
||||||
j, err := json.Marshal(c)
|
j, err := json.Marshal(c)
|
||||||
@ -346,7 +346,7 @@ func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MQKeepAliveWorker() {
|
func MQKeepAliveWorker() {
|
||||||
log.Printf("MQKeepAliveWorker : Starting.")
|
//log.Printf("MQKeepAliveWorker : Starting.")
|
||||||
conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue)
|
conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue)
|
||||||
failOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
failOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
@ -426,7 +426,7 @@ func MQKeepAliveWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MQTidyKeepAliveWorker() {
|
func MQTidyKeepAliveWorker() {
|
||||||
log.Printf("MQTidyKeepAliveWorker : Starting.")
|
//log.Printf("MQTidyKeepAliveWorker : Starting.")
|
||||||
for true {
|
for true {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
for _, v := range clientsKeepAlive {
|
for _, v := range clientsKeepAlive {
|
||||||
|
Loading…
Reference in New Issue
Block a user