diff --git a/.travis.yml b/.travis.yml index db2c8aa05ae..780ea3a3d17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: +- 1.14.x - 1.13.x -- 1.12.x addons: apt: packages: @@ -31,7 +31,7 @@ script: deploy: provider: script - skip_cleanup: true + skip_cleanup: false script: curl -sL http://git.io/goreleaser | bash verbose: true on: diff --git a/go.mod b/go.mod index d8b4887a411..e13b639456c 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/nats-io/nats-server/v2 require ( - github.com/golang/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.3.5 // indirect github.com/nats-io/jwt v0.3.2 - github.com/nats-io/nats.go v1.9.1 - github.com/nats-io/nkeys v0.1.3 + github.com/nats-io/nats.go v1.9.2 + github.com/nats-io/nkeys v0.1.4 github.com/nats-io/nuid v1.0.1 - golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 + golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e ) diff --git a/go.sum b/go.sum index 4a5794dcb81..5cce3487ae5 100644 --- a/go.sum +++ b/go.sum @@ -1,18 +1,18 @@ -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 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.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/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3 h1:6JrEfig+HzTH85yxzhSVbjHRJv9cn0p6n3IngIcM5/k= +github.com/nats-io/nats.go v1.9.2 h1:oDeERm3NcZVrPpdR/JpGdWHMv3oJ8yY30YwxKq+DU2s= +github.com/nats-io/nats.go v1.9.2/go.mod h1:AjGArbfyR50+afOUotNX2Xs5SYHf+CoOa5HH1eEl2HE= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.4 h1:aEsHIssIk6ETN5m2/MD8Y4B2X7FfXrBAUdkyRvbVYzA= +github.com/nats-io/nkeys v0.1.4/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/nats-io/nats.go/.travis.yml b/vendor/github.com/nats-io/nats.go/.travis.yml index 2594b74ea14..b522877402c 100644 --- a/vendor/github.com/nats-io/nats.go/.travis.yml +++ b/vendor/github.com/nats-io/nats.go/.travis.yml @@ -1,8 +1,8 @@ language: go sudo: false go: +- 1.13.x - 1.12.x -- 1.11.x env: - GO111MODULE=off go_import_path: github.com/nats-io/nats.go @@ -20,4 +20,5 @@ before_script: - staticcheck ./... script: - go test -i -race ./... -- if [[ "$TRAVIS_GO_VERSION" =~ 1.12 ]]; then ./scripts/cov.sh TRAVIS; else go test -race -v -p=1 ./... --failfast; fi +- go test -v -run=TestNoRace -p=1 ./... +- if [[ "$TRAVIS_GO_VERSION" =~ 1.13 ]]; then ./scripts/cov.sh TRAVIS; else go test -race -v -p=1 ./... --failfast; fi diff --git a/vendor/github.com/nats-io/nats.go/CODE-OF-CONDUCT.md b/vendor/github.com/nats-io/nats.go/CODE-OF-CONDUCT.md new file mode 100644 index 00000000000..b850d49ee6c --- /dev/null +++ b/vendor/github.com/nats-io/nats.go/CODE-OF-CONDUCT.md @@ -0,0 +1,3 @@ +## Community Code of Conduct + +NATS follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). diff --git a/vendor/github.com/nats-io/nats.go/README.md b/vendor/github.com/nats-io/nats.go/README.md index 83cbbd27d46..c059c253909 100644 --- a/vendor/github.com/nats-io/nats.go/README.md +++ b/vendor/github.com/nats-io/nats.go/README.md @@ -20,7 +20,7 @@ When using or transitioning to Go modules support: ```bash # Go client latest or explicit version go get github.com/nats-io/nats.go/@latest -go get github.com/nats-io/nats.go/@v1.9.1 +go get github.com/nats-io/nats.go/@v1.9.2 # For latest NATS Server, add /v2 at the end go get github.com/nats-io/nats-server/v2 diff --git a/vendor/github.com/nats-io/nats.go/go.mod b/vendor/github.com/nats-io/nats.go/go.mod index f82ceee6dfc..bd7d44a212d 100644 --- a/vendor/github.com/nats-io/nats.go/go.mod +++ b/vendor/github.com/nats-io/nats.go/go.mod @@ -1,7 +1,7 @@ module github.com/nats-io/nats.go require ( - github.com/nats-io/jwt v0.3.0 - github.com/nats-io/nkeys v0.1.0 + github.com/nats-io/jwt v0.3.2 + github.com/nats-io/nkeys v0.1.4 github.com/nats-io/nuid v1.0.1 ) diff --git a/vendor/github.com/nats-io/nats.go/go.sum b/vendor/github.com/nats-io/nats.go/go.sum index 0cd4f64847b..70e81d40562 100644 --- a/vendor/github.com/nats-io/nats.go/go.sum +++ b/vendor/github.com/nats-io/nats.go/go.sum @@ -1,12 +1,14 @@ -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/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +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/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.4 h1:aEsHIssIk6ETN5m2/MD8Y4B2X7FfXrBAUdkyRvbVYzA= +github.com/nats-io/nkeys v0.1.4/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/nats-io/nats.go/nats.go b/vendor/github.com/nats-io/nats.go/nats.go index 911df590e09..f741894b979 100644 --- a/vendor/github.com/nats-io/nats.go/nats.go +++ b/vendor/github.com/nats-io/nats.go/nats.go @@ -45,7 +45,7 @@ import ( // Default Constants const ( - Version = "1.9.1" + Version = "1.9.2" DefaultURL = "nats://127.0.0.1:4222" DefaultPort = 4222 DefaultMaxReconnect = 60 @@ -415,7 +415,6 @@ type Conn struct { respScanf string // The scanf template to extract mux token respMux *Subscription // A single response subscription respMap map[string]chan *Msg // Request map for the response msg channels - respSetup sync.Once // Ensures response subscription occurs once respRand *rand.Rand // Used for generating suffix } @@ -1295,12 +1294,6 @@ func (nc *Conn) createConn() (err error) { return err } - // No clue why, but this stalls and kills performance on Mac (Mavericks). - // https://code.google.com/p/go/issues/detail?id=6930 - //if ip, ok := nc.conn.(*net.TCPConn); ok { - // ip.SetReadBuffer(defaultBufSize) - //} - if nc.pending != nil && nc.bw != nil { // Move to pending buffer. nc.bw.Flush() @@ -2056,31 +2049,21 @@ func (nc *Conn) readLoop() { if nc.ps == nil { nc.ps = &parseState{} } + conn := nc.conn nc.mu.Unlock() + if conn == nil { + return + } + // Stack based buffer. b := make([]byte, defaultBufSize) for { - // ps is thread safe, so RLock is okay - nc.mu.RLock() - sb := nc.isClosed() || nc.isReconnecting() - if sb { - nc.ps = &parseState{} - } - conn := nc.conn - nc.mu.RUnlock() - - if sb || conn == nil { - break - } - - n, err := conn.Read(b) - if err != nil { + if n, err := conn.Read(b); err != nil { nc.processOpErr(err) break - } - if err := nc.parse(b[:n]); err != nil { + } else if err = nc.parse(b[:n]); err != nil { nc.processOpErr(err) break } @@ -2686,23 +2669,6 @@ func (nc *Conn) respHandler(m *Msg) { } } -// Create the response subscription we will use for all -// new style responses. This will be on an _INBOX with an -// additional terminal token. The subscription will be on -// a wildcard. Caller is responsible for ensuring this is -// only called once. -func (nc *Conn) createRespMux(respSub string) error { - s, err := nc.Subscribe(respSub, nc.respHandler) - if err != nil { - return err - } - nc.mu.Lock() - nc.respScanf = strings.Replace(respSub, "*", "%s", -1) - nc.respMux = s - nc.mu.Unlock() - return nil -} - // Helper to setup and send new request style requests. Return the chan to receive the response. func (nc *Conn) createNewRequestAndSend(subj string, data []byte) (chan *Msg, string, error) { // Do setup for the new style if needed. @@ -2714,18 +2680,19 @@ func (nc *Conn) createNewRequestAndSend(subj string, data []byte) (chan *Msg, st respInbox := nc.newRespInbox() token := respInbox[respInboxPrefixLen:] nc.respMap[token] = mch - createSub := nc.respMux == nil - ginbox := nc.respSub - nc.mu.Unlock() - - if createSub { - // Make sure scoped subscription is setup only once. - var err error - nc.respSetup.Do(func() { err = nc.createRespMux(ginbox) }) + if nc.respMux == nil { + // Create the response subscription we will use for all new style responses. + // This will be on an _INBOX with an additional terminal token. The subscription + // will be on a wildcard. + s, err := nc.subscribeLocked(nc.respSub, _EMPTY_, nc.respHandler, nil, false) if err != nil { + nc.mu.Unlock() return nil, token, err } + nc.respScanf = strings.Replace(nc.respSub, "*", "%s", -1) + nc.respMux = s } + nc.mu.Unlock() if err := nc.PublishRequest(subj, respInbox, data); err != nil { return nil, token, err @@ -2949,6 +2916,16 @@ func badQueue(qname string) bool { // subscribe is the internal subscribe function that indicates interest in a subject. func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg, isSync bool) (*Subscription, error) { + if nc == nil { + return nil, ErrInvalidConnection + } + nc.mu.Lock() + s, err := nc.subscribeLocked(subj, queue, cb, ch, isSync) + nc.mu.Unlock() + return s, err +} + +func (nc *Conn) subscribeLocked(subj, queue string, cb MsgHandler, ch chan *Msg, isSync bool) (*Subscription, error) { if nc == nil { return nil, ErrInvalidConnection } @@ -2958,9 +2935,6 @@ func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg, isSyn if queue != "" && badQueue(queue) { return nil, ErrBadQueueName } - nc.mu.Lock() - // ok here, but defer is generally expensive - defer nc.mu.Unlock() // Check for some error conditions. if nc.isClosed() { @@ -3727,6 +3701,10 @@ func (nc *Conn) close(status Status, doCBs bool, err error) { if nc.Opts.ClosedCB != nil { nc.ach.push(func() { nc.Opts.ClosedCB(nc) }) } + } + // If this is terminal, then we have to notify the asyncCB handler that + // it can exit once all async cbs have been dispatched. + if status == CLOSED { nc.ach.close() } nc.mu.Unlock() @@ -3766,6 +3744,19 @@ func (nc *Conn) IsConnected() bool { func (nc *Conn) drainConnection() { // Snapshot subs list. nc.mu.Lock() + + // Check again here if we are in a state to not process. + if nc.isClosed() { + nc.mu.Unlock() + return + } + if nc.isConnecting() || nc.isReconnecting() { + nc.mu.Unlock() + // Move to closed state. + nc.close(CLOSED, true, nil) + return + } + subs := make([]*Subscription, 0, len(nc.subs)) for _, s := range nc.subs { subs = append(subs, s) @@ -3812,7 +3803,7 @@ func (nc *Conn) drainConnection() { nc.mu.Unlock() // Do publish drain via Flush() call. - err := nc.Flush() + err := nc.FlushTimeout(5 * time.Second) if err != nil { pushErr(err) nc.close(CLOSED, true, nil) @@ -3830,20 +3821,23 @@ func (nc *Conn) drainConnection() { // option to know when the connection has moved from draining to closed. func (nc *Conn) Drain() error { nc.mu.Lock() - defer nc.mu.Unlock() - if nc.isClosed() { + nc.mu.Unlock() return ErrConnectionClosed } if nc.isConnecting() || nc.isReconnecting() { + nc.mu.Unlock() + nc.close(CLOSED, true, nil) return ErrConnectionReconnecting } if nc.isDraining() { + nc.mu.Unlock() return nil } - nc.status = DRAINING_SUBS go nc.drainConnection() + nc.mu.Unlock() + return nil } diff --git a/vendor/github.com/nats-io/nkeys/go.mod b/vendor/github.com/nats-io/nkeys/go.mod index 34cad74872c..6cdaeb3cb7c 100644 --- a/vendor/github.com/nats-io/nkeys/go.mod +++ b/vendor/github.com/nats-io/nkeys/go.mod @@ -1,3 +1,3 @@ module github.com/nats-io/nkeys -require golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 +require golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 diff --git a/vendor/github.com/nats-io/nkeys/go.sum b/vendor/github.com/nats-io/nkeys/go.sum index b75b87f0559..8fdcca764cd 100644 --- a/vendor/github.com/nats-io/nkeys/go.sum +++ b/vendor/github.com/nats-io/nkeys/go.sum @@ -1,6 +1,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/nats-io/nkeys/main.go b/vendor/github.com/nats-io/nkeys/main.go index 2ea3f904535..5c7152dccca 100644 --- a/vendor/github.com/nats-io/nkeys/main.go +++ b/vendor/github.com/nats-io/nkeys/main.go @@ -20,7 +20,7 @@ import ( ) // Version is our current version -const Version = "0.1.3" +const Version = "0.1.4" // Errors var ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 256cd29055a..8cf331f65f3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,21 +1,21 @@ # github.com/nats-io/jwt v0.3.2 github.com/nats-io/jwt -# github.com/nats-io/nats.go v1.9.1 +# github.com/nats-io/nats.go v1.9.2 github.com/nats-io/nats.go github.com/nats-io/nats.go/encoders/builtin github.com/nats-io/nats.go/util -# github.com/nats-io/nkeys v0.1.3 +# github.com/nats-io/nkeys v0.1.4 github.com/nats-io/nkeys # github.com/nats-io/nuid v1.0.1 github.com/nats-io/nuid -# golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 +# golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 golang.org/x/crypto/bcrypt -golang.org/x/crypto/ed25519 golang.org/x/crypto/blowfish +golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 # golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e -golang.org/x/sys/windows/svc/eventlog -golang.org/x/sys/windows/svc -golang.org/x/sys/windows/svc/mgr golang.org/x/sys/windows golang.org/x/sys/windows/registry +golang.org/x/sys/windows/svc +golang.org/x/sys/windows/svc/eventlog +golang.org/x/sys/windows/svc/mgr