Moving bulk of amqp play crap into separate lib

in prep for changing the things, introducing more code.
cat-town
Dan Buch 12 years ago
parent d24efe640b
commit 1ab8d7d42c

@ -4,12 +4,12 @@ PACKAGES := $(foreach pkg,\
$(shell ls src/meatballhat.com/gotour-artifacts),\ $(shell ls src/meatballhat.com/gotour-artifacts),\
$(patsubst %,meatballhat.com/gotour-artifacts/%,$(pkg))\ $(patsubst %,meatballhat.com/gotour-artifacts/%,$(pkg))\
) )
PACKAGES += meatballhat.com/amqpfun PACKAGES += meatballhat.com/amqpfun-runner
test: build test: build
go test $(PACKAGES) go test $(PACKAGES)
build: deps fmt build: deps
go install $(PACKAGES) go install $(PACKAGES)
fmt: fmt:

@ -0,0 +1,24 @@
package main
import (
"fmt"
"os"
)
import (
"meatballhat.com/amqpfun"
)
const USAGE = "Usage: amqpfun-runner (publish|consume)"
func main() {
if len(os.Args) < 2 {
fmt.Println(USAGE)
os.Exit(1)
}
if os.Args[1] == "publish" {
amqpfun.Publish()
} else if os.Args[1] == "consume" {
amqpfun.Consume()
}
}

@ -1,4 +1,4 @@
package main package amqpfun
import ( import (
"log" "log"
@ -12,7 +12,7 @@ import (
"github.com/streadway/amqp" "github.com/streadway/amqp"
) )
func publish() { func Publish() {
// Connects opens an AMQP connection from the credentials in the URL. // Connects opens an AMQP connection from the credentials in the URL.
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
if err != nil { if err != nil {
@ -57,7 +57,7 @@ func publish() {
} }
} }
func consume() { func Consume() {
// Connects opens an AMQP connection from the credentials in the URL. // Connects opens an AMQP connection from the credentials in the URL.
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
if err != nil { if err != nil {
@ -183,11 +183,3 @@ func consume() {
// sure to wait for all consumers goroutines to finish before exiting your // sure to wait for all consumers goroutines to finish before exiting your
// process. // process.
} }
func main() {
if os.Args[1] == "publish" {
publish()
} else if os.Args[1] == "consume" {
consume()
}
}
Loading…
Cancel
Save