Attempting to correct Go project layout
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/streadway/amqp"
|
||||
"meatballhat.com/sylvilagus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
connection, err := amqp.Dial(sylvilagus.AMQP_URI)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to connect!: ", err)
|
||||
}
|
||||
|
||||
defer connection.Close()
|
||||
|
||||
channel, err := sylvilagus.CreateHelloTopology(connection)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to build topology!: ", err)
|
||||
}
|
||||
|
||||
hellos, err := channel.Consume("hello-queue", "hello-consumer", false, false, false, false, nil)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to start consuming!:", err)
|
||||
}
|
||||
|
||||
quit := make(chan bool)
|
||||
|
||||
go func(quit chan bool) {
|
||||
log.Println("Consuming...")
|
||||
for hello := range hellos {
|
||||
log.Printf("hello -> %v\n", string(hello.Body))
|
||||
hello.Ack(false)
|
||||
if string(hello.Body) == "quit" {
|
||||
quit <- true
|
||||
return
|
||||
}
|
||||
}
|
||||
}(quit)
|
||||
|
||||
<-quit
|
||||
}
|
Reference in New Issue
Block a user