diff --git a/gotime/Makefile b/gotime/Makefile index 71a245a..d47f342 100644 --- a/gotime/Makefile +++ b/gotime/Makefile @@ -4,12 +4,12 @@ PACKAGES := $(foreach pkg,\ $(shell ls src/meatballhat.com/gotour-artifacts),\ $(patsubst %,meatballhat.com/gotour-artifacts/%,$(pkg))\ ) -PACKAGES += meatballhat.com/amqpfun +PACKAGES += meatballhat.com/amqpfun-runner test: build go test $(PACKAGES) -build: deps fmt +build: deps go install $(PACKAGES) fmt: diff --git a/gotime/src/meatballhat.com/amqpfun-runner/main.go b/gotime/src/meatballhat.com/amqpfun-runner/main.go new file mode 100644 index 0000000..c05a0e3 --- /dev/null +++ b/gotime/src/meatballhat.com/amqpfun-runner/main.go @@ -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() + } +} diff --git a/gotime/src/meatballhat.com/amqpfun/main.go b/gotime/src/meatballhat.com/amqpfun/workers.go similarity index 97% rename from gotime/src/meatballhat.com/amqpfun/main.go rename to gotime/src/meatballhat.com/amqpfun/workers.go index 639c7d4..70e299b 100644 --- a/gotime/src/meatballhat.com/amqpfun/main.go +++ b/gotime/src/meatballhat.com/amqpfun/workers.go @@ -1,4 +1,4 @@ -package main +package amqpfun import ( "log" @@ -12,7 +12,7 @@ import ( "github.com/streadway/amqp" ) -func publish() { +func Publish() { // Connects opens an AMQP connection from the credentials in the URL. conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") if err != nil { @@ -57,7 +57,7 @@ func publish() { } } -func consume() { +func Consume() { // Connects opens an AMQP connection from the credentials in the URL. conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") if err != nil { @@ -183,11 +183,3 @@ func consume() { // sure to wait for all consumers goroutines to finish before exiting your // process. } - -func main() { - if os.Args[1] == "publish" { - publish() - } else if os.Args[1] == "consume" { - consume() - } -}