Attempting to correct Go project layout

This commit is contained in:
Dan Buch
2012-12-01 18:34:55 -05:00
parent bbb709be31
commit 80e5b8fa5e
6 changed files with 9 additions and 24 deletions

View File

@@ -0,0 +1,46 @@
package sylvilagus
import (
"log"
"os"
)
import (
"github.com/streadway/amqp"
)
var AMQP_URI = os.Getenv("SYLVILAGUS_AMQP_URI")
func init() {
if len(AMQP_URI) < 1 {
log.Fatal("SYLVILAGUS_AMQP_URI is not defined!")
}
}
func CreateHelloTopology(connection *amqp.Connection) (*amqp.Channel, error) {
channel, err := connection.Channel()
if err != nil {
log.Println("Failed to get channel!: ", err)
return nil, err
}
err = channel.ExchangeDeclare("hello-exchange", "direct", true, false, false, false, nil)
if err != nil {
log.Println("Failed to declare exchange!: ", err)
return nil, err
}
_, err = channel.QueueDeclare("hello-queue", false, false, false, false, nil)
if err != nil {
log.Println("Failed to declare queue!: ", err)
return nil, err
}
err = channel.QueueBind("hello-queue", "hola", "hello-exchange", false, nil)
if err != nil {
log.Println("Failed to bind to queue!: ", err)
return nil, err
}
return channel, nil
}