test
This commit is contained in:
parent
f7673e7cf1
commit
4728679b7d
21
mq.go
21
mq.go
@ -1,24 +1,5 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/streadway/amqp"
|
||||
//"github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
func Open(c *MQClient) error {
|
||||
var err error
|
||||
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
||||
|
||||
if err != nil {
|
||||
c.Connection.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
c.Channel, err = c.Connection.Channel()
|
||||
if err != nil {
|
||||
c.Channel.Close()
|
||||
c.Connection.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
21
workers.go
21
workers.go
@ -13,6 +13,25 @@ import (
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func (c *MQClient) Open() error {
|
||||
var err error
|
||||
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
|
||||
|
||||
if err != nil {
|
||||
c.Connection.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
c.Channel, err = c.Connection.Channel()
|
||||
if err != nil {
|
||||
c.Channel.Close()
|
||||
c.Connection.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
||||
//log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||
var x ChatWarsMessage
|
||||
@ -24,7 +43,7 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
||||
c.Path = cfg.Rabbit.Path
|
||||
c.SSL = false
|
||||
|
||||
err := Open(c)
|
||||
err := c.Open()
|
||||
|
||||
if err != nil {
|
||||
q, err := c.Channel.QueueDeclare(
|
||||
|
Loading…
Reference in New Issue
Block a user