From d7140a0fd1ee6eb41ad89f089b33a7d968641744 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Fri, 10 May 2019 15:11:30 -0700 Subject: [PATCH] Update for client rename Signed-off-by: Derek Collison --- go.mod | 9 +- go.sum | 43 ++--- logger/log.go | 4 +- logger/syslog.go | 4 +- logger/syslog_test.go | 18 +-- server/client_test.go | 2 +- server/closed_conns_test.go | 4 +- server/events_test.go | 4 +- server/gateway_test.go | 2 +- server/monitor_test.go | 4 +- server/norace_test.go | 4 +- server/ping_test.go | 4 +- server/reload_test.go | 3 +- server/routes_test.go | 4 +- server/server_test.go | 4 +- test/client_auth_test.go | 4 +- test/client_cluster_test.go | 4 +- test/fanout_test.go | 2 +- test/leafnode_test.go | 2 +- test/maxpayload_test.go | 4 +- test/monitor_test.go | 2 +- test/new_routes_test.go | 2 +- test/operator_test.go | 2 +- test/routes_test.go | 2 +- test/tls_test.go | 2 +- .../nats-io/go-nats/staticcheck.ignore | 4 - .../nats-io/{go-nats => nats.go}/.gitignore | 0 .../nats-io/{go-nats => nats.go}/.travis.yml | 8 +- .../{go-nats => nats.go}/GOVERNANCE.md | 0 .../nats-io/{go-nats => nats.go}/LICENSE | 0 .../{go-nats => nats.go}/MAINTAINERS.md | 0 .../nats-io/{go-nats => nats.go}/README.md | 8 +- .../nats-io/{go-nats => nats.go}/TODO.md | 0 .../nats-io/{go-nats => nats.go}/context.go | 2 +- .../nats-io/{go-nats => nats.go}/enc.go | 6 +- .../encoders/builtin/default_enc.go | 0 .../encoders/builtin/gob_enc.go | 0 .../encoders/builtin/json_enc.go | 0 vendor/github.com/nats-io/nats.go/go.mod | 13 ++ vendor/github.com/nats-io/nats.go/go.sum | 25 +++ .../nats-io/{go-nats => nats.go}/nats.go | 148 ++++++++++-------- .../nats-io/{go-nats => nats.go}/netchan.go | 2 +- .../nats-io/{go-nats => nats.go}/parser.go | 0 .../nats-io/nats.go/staticcheck.ignore | 4 + .../nats-io/{go-nats => nats.go}/timer.go | 0 .../nats-io/{go-nats => nats.go}/util/tls.go | 0 .../{go-nats => nats.go}/util/tls_go17.go | 0 vendor/golang.org/x/sys/windows/mkerrors.go | 2 + vendor/golang.org/x/sys/windows/mksyscall.go | 2 + .../x/sys/windows/registry/mksyscall.go | 2 + vendor/modules.txt | 17 +- 51 files changed, 204 insertions(+), 178 deletions(-) delete mode 100644 vendor/github.com/nats-io/go-nats/staticcheck.ignore rename vendor/github.com/nats-io/{go-nats => nats.go}/.gitignore (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/.travis.yml (74%) rename vendor/github.com/nats-io/{go-nats => nats.go}/GOVERNANCE.md (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/LICENSE (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/MAINTAINERS.md (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/README.md (95%) rename vendor/github.com/nats-io/{go-nats => nats.go}/TODO.md (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/context.go (98%) rename vendor/github.com/nats-io/{go-nats => nats.go}/enc.go (98%) rename vendor/github.com/nats-io/{go-nats => nats.go}/encoders/builtin/default_enc.go (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/encoders/builtin/gob_enc.go (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/encoders/builtin/json_enc.go (100%) create mode 100644 vendor/github.com/nats-io/nats.go/go.mod create mode 100644 vendor/github.com/nats-io/nats.go/go.sum rename vendor/github.com/nats-io/{go-nats => nats.go}/nats.go (98%) rename vendor/github.com/nats-io/{go-nats => nats.go}/netchan.go (98%) rename vendor/github.com/nats-io/{go-nats => nats.go}/parser.go (100%) create mode 100644 vendor/github.com/nats-io/nats.go/staticcheck.ignore rename vendor/github.com/nats-io/{go-nats => nats.go}/timer.go (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/util/tls.go (100%) rename vendor/github.com/nats-io/{go-nats => nats.go}/util/tls_go17.go (100%) diff --git a/go.mod b/go.mod index 4637f160..c52b7523 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,10 @@ module github.com/nats-io/nats-server require ( - github.com/nats-io/go-nats v1.7.2 github.com/nats-io/jwt v0.2.4 + github.com/nats-io/nats.go v1.7.3-0.20190510202513-4c154eb68ac6 github.com/nats-io/nkeys v0.0.2 github.com/nats-io/nuid v1.0.1 - golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 - golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c // indirect - golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e - golang.org/x/text v0.3.2 // indirect - golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c // indirect + golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 + golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 ) diff --git a/go.sum b/go.sum index 3531bfe3..63dcd47e 100644 --- a/go.sum +++ b/go.sum @@ -1,49 +1,28 @@ -github.com/nats-io/go-nats v1.7.2 h1:cJujlwCYR8iMz5ofZSD/p2WLW8FabhkQ2lIEVbSvNSA= -github.com/nats-io/go-nats v1.7.2/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0= -github.com/nats-io/jwt v0.0.8 h1:oQsISWFvSmzKEs13h6X7p+8jQaXa9/X2fnBWoU2Zh4g= -github.com/nats-io/jwt v0.0.8/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY= -github.com/nats-io/jwt v0.1.0 h1:xO7kj8fyt0ECycBVG6WtOW+TnX8Aax4tI8i2fwspUro= -github.com/nats-io/jwt v0.1.0/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY= -github.com/nats-io/jwt v0.2.2 h1:tvCi/V+vJjSxOVmh5Zs3FN+n4jWDME4tH8BmGuZcnN0= -github.com/nats-io/jwt v0.2.2/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY= -github.com/nats-io/jwt v0.2.3-0.20190415222205-ef45966189e5 h1:hTRkgUpVZlCym185L0HG6tkO+EQxV4y9YOrsWx7K0wA= -github.com/nats-io/jwt v0.2.3-0.20190415222205-ef45966189e5/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/nats-io/jwt v0.2.4 h1:SZ27ZMqlP8US5QYFE+GPYtZZQa7PZUVZ6lNV3L7Z7EU= github.com/nats-io/jwt v0.2.4/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY= +github.com/nats-io/nats-server v1.4.1/go.mod h1:c8f/fHd2B6Hgms3LtCaI7y6pC4WD1f4SUxcCud5vhBc= +github.com/nats-io/nats.go v1.7.3-0.20190510202513-4c154eb68ac6 h1:0Kv7hRrWmjrqFPpW4Sw+b5nC0KGr/QFhInvpwQvtfac= +github.com/nats-io/nats.go v1.7.3-0.20190510202513-4c154eb68ac6/go.mod h1:lDA0FIyNEl18QqjzdvReBbUZ4AXBJJloRy1lw/blAKk= github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= -github.com/nats-io/nuid v0.0.0-20180712044959-3024a71c3cbe h1:2nFZc8mo/vXfkJX5mTrTUUhHt6mIHwDoamuqIs3U1jU= -github.com/nats-io/nuid v0.0.0-20180712044959-3024a71c3cbe/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nats-io/nuid v1.0.0 h1:44QGdhbiANq8ZCbUkdn6W5bqtg+mHuDE4wOUuxxndFs= -github.com/nats-io/nuid v1.0.0/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= 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-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5 h1:bselrhR0Or1vomJZC8ZIjWtbDmn9OYFLX5Ik9alpJpE= -golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a h1:Igim7XhdOpBnWPuYJ70XcNpq8q3BCACtVgNfoJxOV7g= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170627012538-f7928cfef4d0 h1:zBqTV7BZW0C9WnFZU5Izl5ZfxL5+qtufgtwXGFU4t7g= -golang.org/x/sys v0.0.0-20170627012538-f7928cfef4d0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67 h1:1Fzlr8kkDLQwqMP8GxrhptBLqZG/EDpiATneiZHY998= -golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190411185658-b44545bcd369 h1:aBlRBZoCuZNRDClvfkDoklQqdLzBaA3uViASg2z2p24= -golang.org/x/sys v0.0.0-20190411185658-b44545bcd369/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e h1:bq5BY1tGuaK8HxuwN6pT6kWgTVLeJ5KwuyBpsl1CZL4= -golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190510151030-63859f3815cb/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= diff --git a/logger/log.go b/logger/log.go index 9471cf62..267c8a9d 100644 --- a/logger/log.go +++ b/logger/log.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//Package logger provides logging facilities for the NATS server +// Package logger provides logging facilities for the NATS server package logger import ( diff --git a/logger/syslog.go b/logger/syslog.go index 82bcb0ed..f211ccd0 100644 --- a/logger/syslog.go +++ b/logger/syslog.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -37,7 +37,7 @@ func SetSyslogName(name string) {} // GetSysLoggerTag generates the tag name for use in syslog statements. If // the executable is linked, the name of the link will be used as the tag, -// otherwise, the name of the executable is used. "gnatsd" is the default +// otherwise, the name of the executable is used. "nats-server" is the default // for the NATS server. func GetSysLoggerTag() string { procName := os.Args[0] diff --git a/logger/syslog_test.go b/logger/syslog_test.go index 604ccd16..f4cdff44 100644 --- a/logger/syslog_test.go +++ b/logger/syslog_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -67,14 +67,14 @@ func TestSysLoggerTagGen(t *testing.T) { origArg := os.Args[0] defer restoreArg(origArg) - testTag(t, "gnatsd", "gnatsd") - testTag(t, filepath.Join(".", "gnatsd"), "gnatsd") - testTag(t, filepath.Join("home", "bin", "gnatsd"), "gnatsd") - testTag(t, filepath.Join("..", "..", "gnatsd"), "gnatsd") - testTag(t, "gnatsd.service1", "gnatsd.service1") - testTag(t, "gnatsd_service1", "gnatsd_service1") - testTag(t, "gnatsd-service1", "gnatsd-service1") - testTag(t, "gnatsd service1", "gnatsd service1") + testTag(t, "nats-server", "nats-server") + testTag(t, filepath.Join(".", "nats-server"), "nats-server") + testTag(t, filepath.Join("home", "bin", "nats-server"), "nats-server") + testTag(t, filepath.Join("..", "..", "nats-server"), "nats-server") + testTag(t, "nats-server.service1", "nats-server.service1") + testTag(t, "nats-server_service1", "nats-server_service1") + testTag(t, "nats-server-service1", "nats-server-service1") + testTag(t, "nats-server service1", "nats-server service1") } func TestSysLoggerTag(t *testing.T) { diff --git a/server/client_test.go b/server/client_test.go index 20845485..e358e40e 100644 --- a/server/client_test.go +++ b/server/client_test.go @@ -30,7 +30,7 @@ import ( "crypto/rand" "crypto/tls" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) type serverInfo struct { diff --git a/server/closed_conns_test.go b/server/closed_conns_test.go index ef11183e..e9580e08 100644 --- a/server/closed_conns_test.go +++ b/server/closed_conns_test.go @@ -1,4 +1,4 @@ -// Copyright 2018 The NATS Authors +// Copyright 2018-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -20,7 +20,7 @@ import ( "testing" "time" - nats "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func checkClosedConns(t *testing.T, s *Server, num int, wait time.Duration) { diff --git a/server/events_test.go b/server/events_test.go index 05161bdd..9c2d0f4a 100644 --- a/server/events_test.go +++ b/server/events_test.go @@ -1,4 +1,4 @@ -// Copyright 2018 The NATS Authors +// Copyright 2018-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -25,8 +25,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/jwt" + "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" ) diff --git a/server/gateway_test.go b/server/gateway_test.go index 89b076d1..3482e044 100644 --- a/server/gateway_test.go +++ b/server/gateway_test.go @@ -27,8 +27,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/logger" + "github.com/nats-io/nats.go" ) func init() { diff --git a/server/monitor_test.go b/server/monitor_test.go index a9aafcee..911b0a9a 100644 --- a/server/monitor_test.go +++ b/server/monitor_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -32,7 +32,7 @@ import ( "net" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) const CLIENT_PORT = -1 diff --git a/server/norace_test.go b/server/norace_test.go index 756b4a82..a9b4abe2 100644 --- a/server/norace_test.go +++ b/server/norace_test.go @@ -1,4 +1,4 @@ -// Copyright 2018 The NATS Authors +// Copyright 2018-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -23,7 +23,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) // IMPORTANT: Tests in this file are not executed when running with the -race flag. diff --git a/server/ping_test.go b/server/ping_test.go index aa56f6b4..9bea9eb6 100644 --- a/server/ping_test.go +++ b/server/ping_test.go @@ -1,4 +1,4 @@ -// Copyright 2015-2018 The NATS Authors +// Copyright 2015-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) const PING_CLIENT_PORT = 11228 diff --git a/server/reload_test.go b/server/reload_test.go index 1615fc63..590bb0ea 100644 --- a/server/reload_test.go +++ b/server/reload_test.go @@ -30,9 +30,8 @@ import ( "testing" "time" + "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" - - "github.com/nats-io/go-nats" ) func newServerWithConfig(t *testing.T, configFile string) (*Server, *Options, string) { diff --git a/server/routes_test.go b/server/routes_test.go index fd8eae72..29990bc2 100644 --- a/server/routes_test.go +++ b/server/routes_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func checkNumRoutes(t *testing.T, s *Server, expected int) { diff --git a/server/server_test.go b/server/server_test.go index 6f4fbbad..8c8de54f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -26,7 +26,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func checkFor(t *testing.T, totalWait, sleepDur time.Duration, f func() error) { diff --git a/test/client_auth_test.go b/test/client_auth_test.go index 9255c4bd..a36a1116 100644 --- a/test/client_auth_test.go +++ b/test/client_auth_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018 The NATS Authors +// Copyright 2016-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,7 +19,7 @@ import ( "os" "testing" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func TestMultipleUserAuth(t *testing.T) { diff --git a/test/client_cluster_test.go b/test/client_cluster_test.go index 36e89e34..5dc06636 100644 --- a/test/client_cluster_test.go +++ b/test/client_cluster_test.go @@ -1,4 +1,4 @@ -// Copyright 2013-2018 The NATS Authors +// Copyright 2013-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func TestServerRestartReSliceIssue(t *testing.T) { diff --git a/test/fanout_test.go b/test/fanout_test.go index d11d78d3..b79ee09c 100644 --- a/test/fanout_test.go +++ b/test/fanout_test.go @@ -20,8 +20,8 @@ import ( "sync" "testing" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) // IMPORTANT: Tests in this file are not executed when running with the -race flag. diff --git a/test/leafnode_test.go b/test/leafnode_test.go index 8023cc79..39482046 100644 --- a/test/leafnode_test.go +++ b/test/leafnode_test.go @@ -26,9 +26,9 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/jwt" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" ) diff --git a/test/maxpayload_test.go b/test/maxpayload_test.go index 2bf96819..ecbf30d6 100644 --- a/test/maxpayload_test.go +++ b/test/maxpayload_test.go @@ -1,4 +1,4 @@ -// Copyright 2015-2018 The NATS Authors +// Copyright 2015-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" + "github.com/nats-io/nats.go" ) func TestMaxPayload(t *testing.T) { diff --git a/test/monitor_test.go b/test/monitor_test.go index 49e87032..a4b1abf1 100644 --- a/test/monitor_test.go +++ b/test/monitor_test.go @@ -27,8 +27,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) const CLIENT_PORT = 11422 diff --git a/test/new_routes_test.go b/test/new_routes_test.go index d92afffc..4e576247 100644 --- a/test/new_routes_test.go +++ b/test/new_routes_test.go @@ -22,9 +22,9 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/logger" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) func runNewRouteServer(t *testing.T) (*server.Server, *server.Options) { diff --git a/test/operator_test.go b/test/operator_test.go index 232a5352..a78efb7b 100644 --- a/test/operator_test.go +++ b/test/operator_test.go @@ -17,9 +17,9 @@ import ( "fmt" "testing" - "github.com/nats-io/go-nats" "github.com/nats-io/jwt" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" ) diff --git a/test/routes_test.go b/test/routes_test.go index 37e12fd5..4f4f6006 100644 --- a/test/routes_test.go +++ b/test/routes_test.go @@ -25,8 +25,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) const clientProtoInfo = 1 diff --git a/test/tls_test.go b/test/tls_test.go index 2897d881..d48ca918 100644 --- a/test/tls_test.go +++ b/test/tls_test.go @@ -27,8 +27,8 @@ import ( "testing" "time" - "github.com/nats-io/go-nats" "github.com/nats-io/nats-server/server" + "github.com/nats-io/nats.go" ) func TestTLSConnection(t *testing.T) { diff --git a/vendor/github.com/nats-io/go-nats/staticcheck.ignore b/vendor/github.com/nats-io/go-nats/staticcheck.ignore deleted file mode 100644 index 25bbf020..00000000 --- a/vendor/github.com/nats-io/go-nats/staticcheck.ignore +++ /dev/null @@ -1,4 +0,0 @@ -github.com/nats-io/go-nats/*_test.go:SA2002 -github.com/nats-io/go-nats/*/*_test.go:SA2002 -github.com/nats-io/go-nats/test/context_test.go:SA1012 -github.com/nats-io/go-nats/nats.go:SA6000 diff --git a/vendor/github.com/nats-io/go-nats/.gitignore b/vendor/github.com/nats-io/nats.go/.gitignore similarity index 100% rename from vendor/github.com/nats-io/go-nats/.gitignore rename to vendor/github.com/nats-io/nats.go/.gitignore diff --git a/vendor/github.com/nats-io/go-nats/.travis.yml b/vendor/github.com/nats-io/nats.go/.travis.yml similarity index 74% rename from vendor/github.com/nats-io/go-nats/.travis.yml rename to vendor/github.com/nats-io/nats.go/.travis.yml index b46060de..7163076d 100644 --- a/vendor/github.com/nats-io/go-nats/.travis.yml +++ b/vendor/github.com/nats-io/nats.go/.travis.yml @@ -1,12 +1,12 @@ language: go sudo: false go: +- 1.12.x - 1.11.x -- 1.10.x -go_import_path: github.com/nats-io/go-nats +go_import_path: github.com/nats-io/nats.go install: - go get -t ./... -- go get github.com/nats-io/gnatsd +- go get github.com/nats-io/nats-server - go get github.com/mattn/goveralls - go get github.com/wadey/gocovmerge - go get -u honnef.co/go/tools/cmd/staticcheck @@ -18,4 +18,4 @@ before_script: - staticcheck -ignore "$(cat staticcheck.ignore)" ./... script: - go test -i -race ./... -- if [[ "$TRAVIS_GO_VERSION" =~ 1.11 ]]; then ./scripts/cov.sh TRAVIS; else go test -race ./...; fi +- if [[ "$TRAVIS_GO_VERSION" =~ 1.12 ]]; then ./scripts/cov.sh TRAVIS; else go test -race ./...; fi diff --git a/vendor/github.com/nats-io/go-nats/GOVERNANCE.md b/vendor/github.com/nats-io/nats.go/GOVERNANCE.md similarity index 100% rename from vendor/github.com/nats-io/go-nats/GOVERNANCE.md rename to vendor/github.com/nats-io/nats.go/GOVERNANCE.md diff --git a/vendor/github.com/nats-io/go-nats/LICENSE b/vendor/github.com/nats-io/nats.go/LICENSE similarity index 100% rename from vendor/github.com/nats-io/go-nats/LICENSE rename to vendor/github.com/nats-io/nats.go/LICENSE diff --git a/vendor/github.com/nats-io/go-nats/MAINTAINERS.md b/vendor/github.com/nats-io/nats.go/MAINTAINERS.md similarity index 100% rename from vendor/github.com/nats-io/go-nats/MAINTAINERS.md rename to vendor/github.com/nats-io/nats.go/MAINTAINERS.md diff --git a/vendor/github.com/nats-io/go-nats/README.md b/vendor/github.com/nats-io/nats.go/README.md similarity index 95% rename from vendor/github.com/nats-io/go-nats/README.md rename to vendor/github.com/nats-io/nats.go/README.md index a2bbdf9e..01a550b9 100644 --- a/vendor/github.com/nats-io/go-nats/README.md +++ b/vendor/github.com/nats-io/nats.go/README.md @@ -3,22 +3,22 @@ A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io [![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnats-io%2Fgo-nats.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnats-io%2Fgo-nats?ref=badge_shield) -[![Go Report Card](https://goreportcard.com/badge/github.com/nats-io/go-nats)](https://goreportcard.com/report/github.com/nats-io/go-nats) [![Build Status](https://travis-ci.org/nats-io/go-nats.svg?branch=master)](http://travis-ci.org/nats-io/go-nats) [![GoDoc](https://godoc.org/github.com/nats-io/go-nats?status.svg)](http://godoc.org/github.com/nats-io/go-nats) [![Coverage Status](https://coveralls.io/repos/nats-io/go-nats/badge.svg?branch=master)](https://coveralls.io/r/nats-io/go-nats?branch=master) +[![Go Report Card](https://goreportcard.com/badge/github.com/nats-io/nats.go)](https://goreportcard.com/report/github.com/nats-io/nats.go) [![Build Status](https://travis-ci.org/nats-io/nats.go.svg?branch=master)](http://travis-ci.org/nats-io/nats.go) [![GoDoc](https://godoc.org/github.com/nats-io/nats.go?status.svg)](http://godoc.org/github.com/nats-io/nats.go) [![Coverage Status](https://coveralls.io/repos/nats-io/nats.go/badge.svg?branch=master)](https://coveralls.io/r/nats-io/nats.go?branch=master) ## Installation ```bash # Go client -go get github.com/nats-io/go-nats +go get github.com/nats-io/nats.go # Server -go get github.com/nats-io/gnatsd +go get github.com/nats-io/nats-server ``` ## Basic Usage ```go -import nats "github.com/nats-io/go-nats" +import nats "github.com/nats-io/nats.go" // Connect to a server nc, _ := nats.Connect(nats.DefaultURL) diff --git a/vendor/github.com/nats-io/go-nats/TODO.md b/vendor/github.com/nats-io/nats.go/TODO.md similarity index 100% rename from vendor/github.com/nats-io/go-nats/TODO.md rename to vendor/github.com/nats-io/nats.go/TODO.md diff --git a/vendor/github.com/nats-io/go-nats/context.go b/vendor/github.com/nats-io/nats.go/context.go similarity index 98% rename from vendor/github.com/nats-io/go-nats/context.go rename to vendor/github.com/nats-io/nats.go/context.go index ee5576f5..14aa355e 100644 --- a/vendor/github.com/nats-io/go-nats/context.go +++ b/vendor/github.com/nats-io/nats.go/context.go @@ -93,7 +93,7 @@ func (nc *Conn) oldRequestWithContext(ctx context.Context, subj string, data []b inbox := NewInbox() ch := make(chan *Msg, RequestChanLen) - s, err := nc.subscribe(inbox, _EMPTY_, nil, ch) + s, err := nc.subscribe(inbox, _EMPTY_, nil, ch, true) if err != nil { return nil, err } diff --git a/vendor/github.com/nats-io/go-nats/enc.go b/vendor/github.com/nats-io/nats.go/enc.go similarity index 98% rename from vendor/github.com/nats-io/go-nats/enc.go rename to vendor/github.com/nats-io/nats.go/enc.go index 9a0dd2c0..6d5c2790 100644 --- a/vendor/github.com/nats-io/go-nats/enc.go +++ b/vendor/github.com/nats-io/nats.go/enc.go @@ -1,4 +1,4 @@ -// Copyright 2012-2018 The NATS Authors +// Copyright 2012-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,7 +21,7 @@ import ( "time" // Default Encoders - "github.com/nats-io/go-nats/encoders/builtin" + "github.com/nats-io/nats.go/encoders/builtin" ) // Encoder interface is for all register encoders @@ -234,7 +234,7 @@ func (c *EncodedConn) subscribe(subject, queue string, cb Handler) (*Subscriptio cbValue.Call(oV) } - return c.Conn.subscribe(subject, queue, natsCB, nil) + return c.Conn.subscribe(subject, queue, natsCB, nil, false) } // FlushTimeout allows a Flush operation to have an associated timeout. diff --git a/vendor/github.com/nats-io/go-nats/encoders/builtin/default_enc.go b/vendor/github.com/nats-io/nats.go/encoders/builtin/default_enc.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/encoders/builtin/default_enc.go rename to vendor/github.com/nats-io/nats.go/encoders/builtin/default_enc.go diff --git a/vendor/github.com/nats-io/go-nats/encoders/builtin/gob_enc.go b/vendor/github.com/nats-io/nats.go/encoders/builtin/gob_enc.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/encoders/builtin/gob_enc.go rename to vendor/github.com/nats-io/nats.go/encoders/builtin/gob_enc.go diff --git a/vendor/github.com/nats-io/go-nats/encoders/builtin/json_enc.go b/vendor/github.com/nats-io/nats.go/encoders/builtin/json_enc.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/encoders/builtin/json_enc.go rename to vendor/github.com/nats-io/nats.go/encoders/builtin/json_enc.go diff --git a/vendor/github.com/nats-io/nats.go/go.mod b/vendor/github.com/nats-io/nats.go/go.mod new file mode 100644 index 00000000..608c0436 --- /dev/null +++ b/vendor/github.com/nats-io/nats.go/go.mod @@ -0,0 +1,13 @@ +module github.com/nats-io/nats.go + +require ( + github.com/golang/protobuf v1.3.1 + github.com/nats-io/nats-server v1.4.1 + github.com/nats-io/nkeys v0.0.2 + github.com/nats-io/nuid v1.0.1 + golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect + golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect + golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 // indirect + golang.org/x/text v0.3.2 // indirect + golang.org/x/tools v0.0.0-20190510151030-63859f3815cb // indirect +) diff --git a/vendor/github.com/nats-io/nats.go/go.sum b/vendor/github.com/nats-io/nats.go/go.sum new file mode 100644 index 00000000..958bd2cf --- /dev/null +++ b/vendor/github.com/nats-io/nats.go/go.sum @@ -0,0 +1,25 @@ +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/nats-io/nats-server v1.4.1 h1:Ul1oSOGNV/L8kjr4v6l2f9Yet6WY+LevH1/7cRZ/qyA= +github.com/nats-io/nats-server v1.4.1/go.mod h1:c8f/fHd2B6Hgms3LtCaI7y6pC4WD1f4SUxcCud5vhBc= +github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M= +github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= +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-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug= +golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190510151030-63859f3815cb/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= diff --git a/vendor/github.com/nats-io/go-nats/nats.go b/vendor/github.com/nats-io/nats.go/nats.go similarity index 98% rename from vendor/github.com/nats-io/go-nats/nats.go rename to vendor/github.com/nats-io/nats.go/nats.go index ec43708a..a91afc93 100644 --- a/vendor/github.com/nats-io/go-nats/nats.go +++ b/vendor/github.com/nats-io/nats.go/nats.go @@ -36,7 +36,7 @@ import ( "sync/atomic" "time" - "github.com/nats-io/go-nats/util" + "github.com/nats-io/nats.go/util" "github.com/nats-io/nkeys" "github.com/nats-io/nuid" ) @@ -44,7 +44,7 @@ import ( // Default Constants const ( Version = "1.7.2" - DefaultURL = "nats://localhost:4222" + DefaultURL = "nats://127.0.0.1:4222" DefaultPort = 4222 DefaultMaxReconnect = 60 DefaultReconnectWait = 2 * time.Second @@ -109,6 +109,10 @@ var ( ErrTokenAlreadySet = errors.New("nats: token and token handler both set") ) +func init() { + rand.Seed(time.Now().UnixNano()) +} + // GetDefaultOptions returns default configuration options for the client. func GetDefaultOptions() Options { return Options{ @@ -330,7 +334,7 @@ const ( defaultBufSize = 32768 // The buffered size of the flush "kick" channel - flushChanSize = 1024 + flushChanSize = 1 // Default server pool size srvPoolSize = 4 @@ -350,7 +354,7 @@ type Conn struct { // atomic.* functions crash on 32bit machines if operand is not aligned // at 64bit. See https://github.com/golang/go/issues/599 Statistics - mu sync.Mutex + mu sync.RWMutex // Opts holds the configuration of the Conn. // Modifying the configuration of a running Conn is a race. Opts Options @@ -1189,18 +1193,18 @@ func (nc *Conn) createConn() (err error) { } // We will auto-expand host names if they resolve to multiple IPs - hosts := map[string]struct{}{} + hosts := []string{} u := nc.current.url if net.ParseIP(u.Hostname()) == nil { addrs, _ := net.LookupHost(u.Hostname()) for _, addr := range addrs { - hosts[net.JoinHostPort(addr, u.Port())] = struct{}{} + hosts = append(hosts, net.JoinHostPort(addr, u.Port())) } } // Fall back to what we were given. if len(hosts) == 0 { - hosts[u.Host] = struct{}{} + hosts = append(hosts, u.Host) } // CustomDialer takes precedence. If not set, use Opts.Dialer which @@ -1214,7 +1218,12 @@ func (nc *Conn) createConn() (err error) { dialer = ©Dialer } - for host := range hosts { + if len(hosts) > 1 && !nc.Opts.NoRandomize { + rand.Shuffle(len(hosts), func(i, j int) { + hosts[i], hosts[j] = hosts[j], hosts[i] + }) + } + for _, host := range hosts { nc.conn, err = dialer.Dial("tcp", host) if err == nil { break @@ -1283,8 +1292,10 @@ func (nc *Conn) ConnectedUrl() string { if nc == nil { return _EMPTY_ } - nc.mu.Lock() - defer nc.mu.Unlock() + + nc.mu.RLock() + defer nc.mu.RUnlock() + if nc.status != CONNECTED { return _EMPTY_ } @@ -1296,8 +1307,10 @@ func (nc *Conn) ConnectedAddr() string { if nc == nil { return _EMPTY_ } - nc.mu.Lock() - defer nc.mu.Unlock() + + nc.mu.RLock() + defer nc.mu.RUnlock() + if nc.status != CONNECTED { return _EMPTY_ } @@ -1309,8 +1322,10 @@ func (nc *Conn) ConnectedServerId() string { if nc == nil { return _EMPTY_ } - nc.mu.Lock() - defer nc.mu.Unlock() + + nc.mu.RLock() + defer nc.mu.RUnlock() + if nc.status != CONNECTED { return _EMPTY_ } @@ -1413,11 +1428,10 @@ func (nc *Conn) connect() error { } } nc.initc = false - defer nc.mu.Unlock() - if returnedErr == nil && nc.status != CONNECTED { returnedErr = ErrNoServers } + nc.mu.Unlock() return returnedErr } @@ -1962,14 +1976,14 @@ func (nc *Conn) readLoop() { b := make([]byte, defaultBufSize) for { - // FIXME(dlc): RWLock here? - nc.mu.Lock() + // 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.Unlock() + nc.mu.RUnlock() if sb || conn == nil { break @@ -2276,6 +2290,7 @@ func (nc *Conn) processInfo(info string) error { if err := json.Unmarshal([]byte(info), &ncInfo); err != nil { return err } + // Copy content into connection's info structure. nc.info = ncInfo // The array could be empty/not present on initial connect, @@ -2322,10 +2337,8 @@ func (nc *Conn) processInfo(info string) error { } } // Figure out if we should save off the current non-IP hostname if we encounter a bare IP. - var saveTLS bool - if nc.current != nil && nc.Opts.Secure && !hostIsIP(nc.current.url) { - saveTLS = true - } + saveTLS := nc.current != nil && !hostIsIP(nc.current.url) + // If there are any left in the tmp map, these are new (or restarted) servers // and need to be added to the pool. for curl := range tmp { @@ -2360,9 +2373,9 @@ func (nc *Conn) LastError() error { if nc == nil { return ErrInvalidConnection } - nc.mu.Lock() + nc.mu.RLock() err := nc.err - nc.mu.Unlock() + nc.mu.RUnlock() return err } @@ -2632,7 +2645,7 @@ func (nc *Conn) oldRequest(subj string, data []byte, timeout time.Duration) (*Ms inbox := NewInbox() ch := make(chan *Msg, RequestChanLen) - s, err := nc.subscribe(inbox, _EMPTY_, nil, ch) + s, err := nc.subscribe(inbox, _EMPTY_, nil, ch, false) if err != nil { return nil, err } @@ -2712,14 +2725,14 @@ func respToken(respInbox string) string { // can have wildcards (partial:*, full:>). Messages will be delivered // to the associated MsgHandler. func (nc *Conn) Subscribe(subj string, cb MsgHandler) (*Subscription, error) { - return nc.subscribe(subj, _EMPTY_, cb, nil) + return nc.subscribe(subj, _EMPTY_, cb, nil, false) } // ChanSubscribe will express interest in the given subject and place // all messages received on the channel. // You should not close the channel until sub.Unsubscribe() has been called. func (nc *Conn) ChanSubscribe(subj string, ch chan *Msg) (*Subscription, error) { - return nc.subscribe(subj, _EMPTY_, nil, ch) + return nc.subscribe(subj, _EMPTY_, nil, ch, false) } // ChanQueueSubscribe will express interest in the given subject. @@ -2729,7 +2742,7 @@ func (nc *Conn) ChanSubscribe(subj string, ch chan *Msg) (*Subscription, error) // You should not close the channel until sub.Unsubscribe() has been called. // Note: This is the same than QueueSubscribeSyncWithChan. func (nc *Conn) ChanQueueSubscribe(subj, group string, ch chan *Msg) (*Subscription, error) { - return nc.subscribe(subj, group, nil, ch) + return nc.subscribe(subj, group, nil, ch, false) } // SubscribeSync will express interest on the given subject. Messages will @@ -2739,10 +2752,7 @@ func (nc *Conn) SubscribeSync(subj string) (*Subscription, error) { return nil, ErrInvalidConnection } mch := make(chan *Msg, nc.Opts.SubChanLen) - s, e := nc.subscribe(subj, _EMPTY_, nil, mch) - if s != nil { - s.typ = SyncSubscription - } + s, e := nc.subscribe(subj, _EMPTY_, nil, mch, true) return s, e } @@ -2751,7 +2761,7 @@ func (nc *Conn) SubscribeSync(subj string) (*Subscription, error) { // only one member of the group will be selected to receive any given // message asynchronously. func (nc *Conn) QueueSubscribe(subj, queue string, cb MsgHandler) (*Subscription, error) { - return nc.subscribe(subj, queue, cb, nil) + return nc.subscribe(subj, queue, cb, nil, false) } // QueueSubscribeSync creates a synchronous queue subscriber on the given @@ -2760,10 +2770,7 @@ func (nc *Conn) QueueSubscribe(subj, queue string, cb MsgHandler) (*Subscription // given message synchronously using Subscription.NextMsg(). func (nc *Conn) QueueSubscribeSync(subj, queue string) (*Subscription, error) { mch := make(chan *Msg, nc.Opts.SubChanLen) - s, e := nc.subscribe(subj, queue, nil, mch) - if s != nil { - s.typ = SyncSubscription - } + s, e := nc.subscribe(subj, queue, nil, mch, true) return s, e } @@ -2774,11 +2781,11 @@ func (nc *Conn) QueueSubscribeSync(subj, queue string) (*Subscription, error) { // You should not close the channel until sub.Unsubscribe() has been called. // Note: This is the same than ChanQueueSubscribe. func (nc *Conn) QueueSubscribeSyncWithChan(subj, queue string, ch chan *Msg) (*Subscription, error) { - return nc.subscribe(subj, queue, nil, ch) + return nc.subscribe(subj, queue, nil, ch, false) } // subscribe is the internal subscribe function that indicates interest in a subject. -func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg) (*Subscription, error) { +func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg, isSync bool) (*Subscription, error) { if nc == nil { return nil, ErrInvalidConnection } @@ -2809,9 +2816,12 @@ func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg) (*Sub sub.typ = AsyncSubscription sub.pCond = sync.NewCond(&sub.mu) go nc.waitForMsgs(sub) - } else { + } else if !isSync { sub.typ = ChanSubscription sub.mch = ch + } else { // Sync Subscription + sub.typ = SyncSubscription + sub.mch = ch } nc.subsMu.Lock() @@ -2835,8 +2845,8 @@ func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg) (*Sub // NumSubscriptions returns active number of subscriptions. func (nc *Conn) NumSubscriptions() int { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return len(nc.subs) } @@ -3366,8 +3376,8 @@ func (nc *Conn) Flush() error { // Buffered will return the number of bytes buffered to be sent to the server. // FIXME(dlc) take into account disconnected state. func (nc *Conn) Buffered() (int, error) { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() if nc.isClosed() || nc.bw == nil { return -1, ErrConnectionClosed } @@ -3515,27 +3525,29 @@ func (nc *Conn) close(status Status, doCBs bool) { // Close will close the connection to the server. This call will release // all blocking calls, such as Flush() and NextMsg() func (nc *Conn) Close() { - nc.close(CLOSED, true) + if nc != nil { + nc.close(CLOSED, true) + } } // IsClosed tests if a Conn has been closed. func (nc *Conn) IsClosed() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.isClosed() } // IsReconnecting tests if a Conn is reconnecting. func (nc *Conn) IsReconnecting() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.isReconnecting() } // IsConnected tests if a Conn is connected. func (nc *Conn) IsConnected() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.isConnected() } @@ -3627,8 +3639,8 @@ func (nc *Conn) Drain() error { // IsDraining tests if a Conn is in the draining state. func (nc *Conn) IsDraining() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.isDraining() } @@ -3651,8 +3663,8 @@ func (nc *Conn) getServers(implicitOnly bool) []string { // authentication is enabled, use UserInfo or Token when connecting with // these urls. func (nc *Conn) Servers() []string { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.getServers(false) } @@ -3660,15 +3672,15 @@ func (nc *Conn) Servers() []string { // after a connection has been established. If authentication is enabled, // use UserInfo or Token when connecting with these urls. func (nc *Conn) DiscoveredServers() []string { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.getServers(true) } // Status returns the current state of the connection. func (nc *Conn) Status() Status { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.status } @@ -3724,22 +3736,22 @@ func (nc *Conn) Stats() Statistics { // This is set by the server configuration and delivered to the client // upon connect. func (nc *Conn) MaxPayload() int64 { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.info.MaxPayload } // AuthRequired will return if the connected server requires authorization. func (nc *Conn) AuthRequired() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.info.AuthRequired } // TLSRequired will return if the connected server requires TLS connections. func (nc *Conn) TLSRequired() bool { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() return nc.info.TLSRequired } @@ -3797,8 +3809,8 @@ func (nc *Conn) Barrier(f func()) error { // This function returns ErrNoClientIDReturned if the server is of a // version prior to 1.2.0. func (nc *Conn) GetClientID() (uint64, error) { - nc.mu.Lock() - defer nc.mu.Unlock() + nc.mu.RLock() + defer nc.mu.RUnlock() if nc.isClosed() { return 0, ErrConnectionClosed } diff --git a/vendor/github.com/nats-io/go-nats/netchan.go b/vendor/github.com/nats-io/nats.go/netchan.go similarity index 98% rename from vendor/github.com/nats-io/go-nats/netchan.go rename to vendor/github.com/nats-io/nats.go/netchan.go index add3cba5..fd86d065 100644 --- a/vendor/github.com/nats-io/go-nats/netchan.go +++ b/vendor/github.com/nats-io/nats.go/netchan.go @@ -107,5 +107,5 @@ func (c *EncodedConn) bindRecvChan(subject, queue string, channel interface{}) ( chVal.Send(oPtr) } - return c.Conn.subscribe(subject, queue, cb, nil) + return c.Conn.subscribe(subject, queue, cb, nil, false) } diff --git a/vendor/github.com/nats-io/go-nats/parser.go b/vendor/github.com/nats-io/nats.go/parser.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/parser.go rename to vendor/github.com/nats-io/nats.go/parser.go diff --git a/vendor/github.com/nats-io/nats.go/staticcheck.ignore b/vendor/github.com/nats-io/nats.go/staticcheck.ignore new file mode 100644 index 00000000..01d07d66 --- /dev/null +++ b/vendor/github.com/nats-io/nats.go/staticcheck.ignore @@ -0,0 +1,4 @@ +github.com/nats-io/nats.go/*_test.go:SA2002 +github.com/nats-io/nats.go/*/*_test.go:SA2002 +github.com/nats-io/nats.go/test/context_test.go:SA1012 +github.com/nats-io/nats.go/nats.go:SA6000 diff --git a/vendor/github.com/nats-io/go-nats/timer.go b/vendor/github.com/nats-io/nats.go/timer.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/timer.go rename to vendor/github.com/nats-io/nats.go/timer.go diff --git a/vendor/github.com/nats-io/go-nats/util/tls.go b/vendor/github.com/nats-io/nats.go/util/tls.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/util/tls.go rename to vendor/github.com/nats-io/nats.go/util/tls.go diff --git a/vendor/github.com/nats-io/go-nats/util/tls_go17.go b/vendor/github.com/nats-io/nats.go/util/tls_go17.go similarity index 100% rename from vendor/github.com/nats-io/go-nats/util/tls_go17.go rename to vendor/github.com/nats-io/nats.go/util/tls_go17.go diff --git a/vendor/golang.org/x/sys/windows/mkerrors.go b/vendor/golang.org/x/sys/windows/mkerrors.go index cbf123ef..a204e6ca 100644 --- a/vendor/golang.org/x/sys/windows/mkerrors.go +++ b/vendor/golang.org/x/sys/windows/mkerrors.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build generate + package windows //go:generate ./mkerrors.bash zerrors_windows.go diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go index fb7db0ef..62770572 100644 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/mksyscall.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build generate + package windows //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go diff --git a/vendor/golang.org/x/sys/windows/registry/mksyscall.go b/vendor/golang.org/x/sys/windows/registry/mksyscall.go index 0ac95ffe..cf843ce2 100644 --- a/vendor/golang.org/x/sys/windows/registry/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/registry/mksyscall.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build generate + package registry //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 54cda8ec..485690e0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,24 +1,19 @@ -# github.com/nats-io/go-nats v1.7.2 -github.com/nats-io/go-nats -github.com/nats-io/go-nats/encoders/builtin -github.com/nats-io/go-nats/util # github.com/nats-io/jwt v0.2.4 github.com/nats-io/jwt -# github.com/nats-io/nats-server v1.4.1 -github.com/nats-io/nats-server/server -github.com/nats-io/nats-server/conf -github.com/nats-io/nats-server/logger -github.com/nats-io/nats-server/server/pse +# github.com/nats-io/nats.go v1.7.3-0.20190510202513-4c154eb68ac6 +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.0.2 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-20190426145343-a29dc8fdc734 +# golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 golang.org/x/crypto/bcrypt golang.org/x/crypto/ed25519 golang.org/x/crypto/blowfish golang.org/x/crypto/ed25519/internal/edwards25519 -# golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e +# golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 golang.org/x/sys/windows/svc/eventlog golang.org/x/sys/windows/svc golang.org/x/sys/windows/svc/debug