Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19 from nats-io/misc_typos_trace
Browse files Browse the repository at this point in the history
Fix typos, add ability to trace network, udpate nats-server
  • Loading branch information
ripienaar authored Dec 31, 2019
2 parents ff59dab + 8f7fd1f commit 5e1471e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ dockers:
image_templates:
- "synadia/jsm:latest"
- "synadia/jsm:{{.Version}}"
extra_files:
- README.md

checksum:
name_template: "SHA256SUMS"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Statistics:
Active Observables: 0
```

Now let's add in some messages. You can use `nats-pub` or `nats-bench`. Or even `nats-req` to see the publish ack being returned.
Now let's add in some messages. You can use `nats-pub` or `nats-bench`. Or even `nats-req` to see the publish ack being returned (these are included in the `synadia/jsm:latest` docker image).

```
> nats-pub sub1 hello
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/dustin/go-humanize v1.0.0
github.com/nats-io/nats-server/v2 v2.1.3-0.20191218221812-ecfe7aeb89ee
github.com/nats-io/nats-server/v2 v2.1.3-0.20191230212518-e7866c0b9aa5
github.com/nats-io/nats.go v1.9.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/nats-io/jwt v0.3.0 h1:xdnzwFETV++jNc4W1mw//qFyJGb2ABOombmZJQS4+Qo=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2 h1:+RB5hMpXUUA2dfxuhBTEkMOrYmM+gKIZYS1KjSostMI=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
github.com/nats-io/nats-server/v2 v2.1.3-0.20191218221812-ecfe7aeb89ee h1:UeMPWKHoe932LHfcTdw/DsqjH5OoiAjzgND7F543F4E=
github.com/nats-io/nats-server/v2 v2.1.3-0.20191218221812-ecfe7aeb89ee/go.mod h1:WRWcbeBX1Cs0tp75BadfuF+geW6G25EUY0Utg1Sy/7w=
github.com/nats-io/nats-server/v2 v2.1.3-0.20191230212518-e7866c0b9aa5 h1:Eb+bv0ms4LQ5MbA1SHBTeo0rfWxbfwRuazAEuBJ1Su4=
github.com/nats-io/nats-server/v2 v2.1.3-0.20191230212518-e7866c0b9aa5/go.mod h1:WRWcbeBX1Cs0tp75BadfuF+geW6G25EUY0Utg1Sy/7w=
github.com/nats-io/nats.go v1.9.1 h1:ik3HbLhZ0YABLto7iX80pZLPw/6dx3T+++MZJwLnMrQ=
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4=
Expand Down
9 changes: 9 additions & 0 deletions jsm/jetstreammgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -245,11 +246,19 @@ func (j *JetStreamMgmt) requestAndUnMarshal(t string, payload []byte, target int
}

func (j *JetStreamMgmt) request(t string, payload []byte) (msg *nats.Msg, err error) {
if os.Getenv("JSM_TRACE") == "1" {
fmt.Printf(">>> %s:\n%s\n---\n", t, string(payload))
}

resp, err := j.nc.Request(t, payload, j.timeout)
if err != nil {
return nil, err
}

if os.Getenv("JSM_TRACE") == "1" {
fmt.Printf("<<<\n%s\n---\n", string(resp.Data))
}

if strings.HasPrefix(string(resp.Data), "-ERR") {
return nil, fmt.Errorf(strings.TrimPrefix(string(resp.Data), "-ERR "))
}
Expand Down
4 changes: 2 additions & 2 deletions jsm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func main() {

jsm.Flag("server", "NATS servers").Short('s').Default("localhost:4222").StringVar(&servers)
jsm.Flag("creds", "User credentials").StringVar(&creds)
jsm.Flag("tlscert", "TLS public certifcate").ExistingFileVar(&tlsCert)
jsm.Flag("tlscert", "TLS public certificate").ExistingFileVar(&tlsCert)
jsm.Flag("tlskey", "TLS private key").ExistingFileVar(&tlsCert)
jsm.Flag("tlsca", "TLS certifcate authority chain").ExistingFileVar(&tlsCA)
jsm.Flag("tlsca", "TLS certificate authority chain").ExistingFileVar(&tlsCA)
jsm.Flag("timeout", "Time to wait on responses from JetStream").Default("2s").DurationVar(&timeout)

configureActCommand(jsm)
Expand Down

0 comments on commit 5e1471e

Please sign in to comment.