Skip to content

Commit

Permalink
Use key = val format for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
birkland committed Oct 12, 2017
1 parent c217257 commit 9ee514b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,37 @@ If you have `go` installed, you may fetch and build via
If you run with no arguments, it will attempt to connect to a STOMP messaging enndpoint on localhost (port 61613). This will connect to a locally-running Fedora configured with default settings.

fcr-listen

## Usage

Use the `-h` or `--help` flag to see the options and defaults:

<pre>
$ fcr-listen -h
Usage of /path/to/fcr-listen:
-host string
STOMP connection host or IP (default "localhost")
-port int
STOMP connection port (default 61613)
-subscribe string
Queue or topic to subscribe to (default "/topic/fedora")
</pre>

$ fcr-listen -h
Usage of /path/to/fcr-listen:
-host string
STOMP connection host or IP (default "localhost")
-port int
STOMP connection port (default 61613)
-subscribe string
Queue or topic to subscribe to (default "/topic/fedora")

Override whatever defaults you wish

If no connection is possibe (i.e. Fedora or its messaging bus are down), it will try to connect every three seconds in an infinite loop, printing to STDERR each time:
<pre>
$ fcr-listen
2017/10/12 15:07:08 main.go:39: Could not connect! dial tcp [::1]:61613: connectex: No connection could be made because the target machine actively refused it.
2017/10/12 15:07:11 main.go:39: Could not connect! dial tcp [::1]:61613: connectex: No connection could be made because the target machine actively refused it.
</pre>

$ fcr-listen

2017/10/12 15:07:08 main.go:39: Could not connect! dial tcp [::1]:61613: connectex: No connection could be made because the target machine actively refused it.
2017/10/12 15:07:11 main.go:39: Could not connect! dial tcp [::1]:61613: connectex: No connection could be made because the target machine actively refused it.

If successful, you'll see a logging message (sent to STDERR)
<pre>
# fcr-listen
2017/10/12 19:08:30 main.go:65: Subscribed to /topic/fedora
</pre>

# fcr-listen
2017/10/12 19:08:30 main.go:65: Subscribed to /topic/fedora

For each message recieved, the following will be printed to STDOUT
* Message headers, with keys and values separated by a single space

* Message headers, with keys and values separated by a `=`.
* When run on a tty supporting color, these will be printed in cyan. Headers that begin with `org.fcrepo` will be in bold
* Message body
* When run on a tty supporting color, this will be printed in orange
Expand All @@ -68,6 +66,7 @@ To produce a statically linked, platform-specific binary (for example, 64-bit li

Consult the [go documentation](https://golang.org/doc/install/source#environment) for valid values of `GOOS` and `GOARCH`.
Some ubiquitous values are:

* `GOOS=linux GOARCH=amd64`
* `GOOS=darwin GOARCH=amd64`
* `GOOS=windows GOARCH=amd64`
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func listen(conn *stomp.Conn) (err error) {
fmt.Println()

for i := 0; i < msg.Header.Len(); i++ {
printHeader(fmt.Sprint(msg.Header.GetAt(i)))
key, val := msg.Header.GetAt(i);
printHeader(fmt.Sprintf("%s = %s", key, val))
}

printBody(string(msg.Body[:]))
Expand Down

0 comments on commit 9ee514b

Please sign in to comment.