Simple wrapper around streadway/amqp with syncronous functions.
Install:
go get -u github.com/edadeal/lepus
Import:
import "github.com/edadeal/lepus"
func main() {
conn, err := amqp.Dial("amqp://lepus:[email protected]:5672/lepus")
if err != nil {
log.Fatal(err)
}
defer conn.Close()
ch, err := lepus.SyncChannel(conn.Channel())
if err != nil {
t.Fatal(err)
}
_, err = ch.QueueDeclare(
"test", // name
true, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
if err != nil {
t.Fatal(err)
}
state, err := ch.PublishAndWait(
"", // exchange
"test", // routing key
true, // mandatory
false,
amqp.Publishing{
DeliveryMode: amqp.Persistent,
ContentType: "text/plain",
Body: []byte("Hello, lepus!"),
},
)
if err != nil {
t.Fatal(err)
}
log.Printf("Published: %t", state == lepus.StatePublished)
}