chirpnest/mq.go

25 lines
391 B
Go
Raw Normal View History

2019-05-03 05:58:36 +02:00
package main
2019-06-28 10:13:25 +02:00
2019-06-28 10:13:56 +02:00
import (
"github.com/streadway/amqp"
)
2019-06-28 10:30:16 +02:00
func Open(c *MQClient) error {
2019-06-28 10:25:37 +02:00
var err error
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
2019-06-28 10:18:48 +02:00
if err != nil {
c.Connection.Close()
return err
}
2019-06-28 10:25:37 +02:00
c.Channel, err = c.Connection.Channel()
2019-06-28 10:18:48 +02:00
if err != nil {
c.Channel.Close()
c.Connection.Close()
return err
}
2019-06-28 10:14:10 +02:00
return err
2019-06-28 10:13:25 +02:00
}