You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.2 KiB
64 lines
2.2 KiB
Index: src/github.com/starkandwayne/nats/nats.go |
|
--- src/github.com/starkandwayne/nats/nats.go.orig 2018-06-12 08:16:48.957155000 +0200 |
|
+++ src/github.com/starkandwayne/nats/nats.go 2018-06-12 08:20:16.605152000 +0200 |
|
@@ -13,9 +13,9 @@ |
|
) |
|
|
|
var message = "Usage: nats sub or nats pub" |
|
-var subMessage = "Usage: nats sub [-s server url] [--cert] [--key] [--ca] [-t] <subject> \n" |
|
-var pubMessage = "Usage: nats pub [-s server url] [--cert] [--key] [--ca] [-t] <subject> <msg> \n" |
|
-var reqMessage = "Usage: nats req [-s server url] [--cert] [--key] [--ca] [-t] [-w] <subject> <msg> \n" |
|
+var subMessage = "Usage: nats sub [-s url] [--cert] [--key] [--ca] [-t] [-r] <subject> \n" |
|
+var pubMessage = "Usage: nats pub [-s url] [--cert] [--key] [--ca] [-t] <subject> <msg> \n" |
|
+var reqMessage = "Usage: nats req [-s url] [--cert] [--key] [--ca] [-t] [-r] [-w] <subject> <msg> \n" |
|
var index = 0 |
|
|
|
func usage() { |
|
@@ -24,12 +24,12 @@ |
|
|
|
func printMsg(m *nats.Msg, i int) { |
|
index += 1 |
|
- fmt.Printf("[#%d] Received on [%s]: '%s'\n", i, m.Subject, string(m.Data)) |
|
+ fmt.Printf("subject [%s]: [#%d]: received message \"%s\"\n", m.Subject, i, string(m.Data)) |
|
} |
|
|
|
func printTimeMsg(m *nats.Msg, i int) { |
|
index += 1 |
|
- log.Printf("[#%d] Received on [%s]: '%s'\n", i, m.Subject, string(m.Data)) |
|
+ log.Printf("subject [%s]: [#%d]: received message \"%s\"\n", m.Subject, i, string(m.Data)) |
|
} |
|
|
|
func printRaw(m *nats.Msg) { |
|
@@ -89,9 +89,10 @@ |
|
subj, msg := args[0], []byte(args[1]) |
|
|
|
nc.Publish(subj, msg) |
|
+ nc.Flush() |
|
nc.Close() |
|
|
|
- fmt.Printf("Published [%s] : '%s'\n", subj, msg) |
|
+ fmt.Printf("subject [%s]: published message \"%s\"\n", subj, msg) |
|
}, |
|
}, |
|
{ |
|
@@ -142,7 +143,7 @@ |
|
} |
|
}) |
|
|
|
- fmt.Printf("Listening on [%s]\n", subj) |
|
+ fmt.Printf("subject [%s]: listening for message\n", subj) |
|
} |
|
runtime.Goexit() |
|
}, |
|
@@ -184,9 +185,9 @@ |
|
|
|
resp, err := nc.Request(subj, msg, timeout) |
|
if err != nil { |
|
- log.Fatal("Error during request:", err) |
|
+ log.Fatalf("Error during request: %v\n", err) |
|
} |
|
- fmt.Printf("Published [%s] : '%s'\n", subj, msg) |
|
+ fmt.Printf("subject [%s]: published message \"%s\"\n", subj, msg) |
|
|
|
if rawoutput { |
|
printRaw(resp)
|
|
|