From ebc27eef77868fa44daed7cfb0ea129690029da8 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 26 May 2020 16:03:12 +0100 Subject: Add -c conntype for necessary tools to allow local connection to be used --- cmd/addtoqueue/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'cmd/addtoqueue') diff --git a/cmd/addtoqueue/main.go b/cmd/addtoqueue/main.go index 8e4ecd2..57087ca 100644 --- a/cmd/addtoqueue/main.go +++ b/cmd/addtoqueue/main.go @@ -14,7 +14,7 @@ import ( "rescribe.xyz/bookpipeline" ) -const usage = `Usage: addtoqueue qname msg +const usage = `Usage: addtoqueue [-c conn] qname msg addtoqueue adds a message to a queue. @@ -44,6 +44,7 @@ type QueuePipeliner interface { } func main() { + conntype := flag.String("c", "aws", "connection type ('aws' or 'local')") flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), usage) flag.PrintDefaults() @@ -58,7 +59,15 @@ func main() { var n NullWriter quietlog := log.New(n, "", 0) var conn QueuePipeliner - conn = &bookpipeline.AwsConn{Region: "eu-west-2", Logger: quietlog} + + switch *conntype { + case "aws": + conn = &bookpipeline.AwsConn{Region: "eu-west-2", Logger: quietlog} + case "local": + conn = &bookpipeline.LocalConn{Logger: quietlog} + default: + log.Fatalln("Unknown connection type") + } err := conn.Init() if err != nil { -- cgit v1.2.1-24-ge1ad