From 7d9eac9c0ba87cdfd575926c26773175b730f9b2 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sat, 20 Jan 2018 20:40:26 +0100 Subject: [PATCH] cmd/mconnect-discover: simple tool to perform discovery --- cmd/mconnect-discover/main.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cmd/mconnect-discover/main.go diff --git a/cmd/mconnect-discover/main.go b/cmd/mconnect-discover/main.go new file mode 100644 index 0000000..8f46c11 --- /dev/null +++ b/cmd/mconnect-discover/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/bboozzoo/mconnect/discovery" + "github.com/bboozzoo/mconnect/logger" +) + +var Stderr = os.Stderr + +func main() { + ctx := context.Background() + ctx = logger.WithContext(ctx, logger.New()) + + log := logger.FromContext(ctx) + + log.Printf("setting up listener") + l, err := discovery.NewListener() + if err != nil { + fmt.Fprintf(Stderr, "error: failed to setup listener: %v\n", + err) + os.Exit(1) + } + + for { + log.Printf("receive wait") + l.Receive(ctx) + } +}