Skip to content

Commit

Permalink
Merge pull request #460 from nats-io/change_default_url
Browse files Browse the repository at this point in the history
[CHANGED] DefaultURL changed to "nats://127.0.0.1:4222"
  • Loading branch information
kozlovic authored May 10, 2019
2 parents 36d30b0 + 8df1cb3 commit d15e194
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go:
go_import_path: github.com/nats-io/go-nats
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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io
go get github.com/nats-io/go-nats

# Server
go get github.com/nats-io/gnatsd
go get github.com/nats-io/nats-server
```

## Basic Usage
Expand Down
2 changes: 1 addition & 1 deletion nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
"testing"
"time"

"github.com/nats-io/gnatsd/server"
gnatsd "github.com/nats-io/gnatsd/test"
"github.com/nats-io/nats-server/server"
natsserver "github.com/nats-io/nats-server/test"
"github.com/nats-io/nkeys"
)

Expand Down Expand Up @@ -112,13 +112,13 @@ var reconnectOpts = Options{
}

func RunServerOnPort(port int) *server.Server {
opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Port = port
return RunServerWithOptions(&opts)
}

func RunServerWithOptions(opts *server.Options) *server.Server {
return gnatsd.RunServer(opts)
return natsserver.RunServer(opts)
}

func TestReconnectServerStats(t *testing.T) {
Expand Down Expand Up @@ -1045,25 +1045,25 @@ func TestAsyncINFO(t *testing.T) {
if err != nil || c.ps.state != OP_START {
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
}
// Pool now should contain localhost:4222 (the default URL) and localhost:5222
checkPool("localhost:4222", "localhost:5222")
// Pool now should contain 127.0.0.1:4222 (the default URL), localhost:4222 and localhost:5222
checkPool("127.0.0.1:4222", "localhost:4222", "localhost:5222")

// Make sure that if client receives the same, it is not added again.
err = c.parse(info)
if err != nil || c.ps.state != OP_START {
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
}
// Pool should still contain localhost:4222 (the default URL) and localhost:5222
checkPool("localhost:4222", "localhost:5222")
// Pool should still contain 127.0.0.1:4222 (the default URL), localhost:4222 and localhost:5222
checkPool("127.0.0.1:4222", "localhost:4222", "localhost:5222")

// Receive a new URL
info = []byte("INFO {\"connect_urls\":[\"localhost:4222\", \"localhost:5222\", \"localhost:6222\"]}\r\n")
err = c.parse(info)
if err != nil || c.ps.state != OP_START {
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
}
// Pool now should contain localhost:4222 (the default URL) localhost:5222 and localhost:6222
checkPool("localhost:4222", "localhost:5222", "localhost:6222")
// Pool now should contain 127.0.0.1:4222 (the default URL), localhost:4222, localhost:5222 and localhost:6222
checkPool("127.0.0.1:4222", "localhost:4222", "localhost:5222", "localhost:6222")

// Check that pool may be randomized on setup, but new URLs are always
// added at end of pool.
Expand Down Expand Up @@ -1130,7 +1130,7 @@ func TestConnServers(t *testing.T) {
}

// check the default url
validateURLs(c.Servers(), "nats://localhost:4222")
validateURLs(c.Servers(), "nats://127.0.0.1:4222")
if len(c.DiscoveredServers()) != 0 {
t.Fatalf("Expected no discovered servers")
}
Expand All @@ -1141,7 +1141,7 @@ func TestConnServers(t *testing.T) {
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
}
// Server list should now contain both the default and the new url.
validateURLs(c.Servers(), "nats://localhost:4222", "nats://localhost:5222")
validateURLs(c.Servers(), "nats://127.0.0.1:4222", "nats://localhost:5222")
// Discovered servers should only contain the new url.
validateURLs(c.DiscoveredServers(), "nats://localhost:5222")

Expand Down Expand Up @@ -1302,7 +1302,7 @@ SUAMK2FG4MI6UE3ACF3FK3OIQBCEIEZV7NSWFFEW63UXMRLFM2XLAXK4GY
func runTrustServer() *server.Server {
kp, _ := nkeys.FromSeed(oSeed)
pub, _ := kp.PublicKey()
opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Port = TEST_PORT
opts.TrustedKeys = []string{string(pub)}
s := RunServerWithOptions(&opts)
Expand Down Expand Up @@ -1407,7 +1407,7 @@ func TestUserCredentialsChainedFileNotFoundError(t *testing.T) {
// Setup opts for both servers.
kp, _ := nkeys.FromSeed(oSeed)
pub, _ := kp.PublicKey()
opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Port = -1
opts.Cluster.Port = -1
opts.TrustedKeys = []string{string(pub)}
Expand Down Expand Up @@ -1466,7 +1466,7 @@ func TestNkeyAuth(t *testing.T) {
kp, _ := nkeys.FromSeed(seed)
pub, _ := kp.PublicKey()

sopts := gnatsd.DefaultTestOptions
sopts := natsserver.DefaultTestOptions
sopts.Port = TEST_PORT
sopts.Nkeys = []*server.NkeyUser{&server.NkeyUser{Nkey: string(pub)}}
ts := RunServerWithOptions(&sopts)
Expand Down Expand Up @@ -1633,7 +1633,7 @@ func TestLookupHostResultIsRandomized(t *testing.T) {
t.Skip("Was looking for IPv4 and IPv6 addresses for localhost to perform test")
}

opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Host = "127.0.0.1"
opts.Port = TEST_PORT
s1 := RunServerWithOptions(&opts)
Expand Down Expand Up @@ -1667,7 +1667,7 @@ func TestLookupHostResultIsNotRandomizedWithNoRandom(t *testing.T) {
t.Skip("Was looking for IPv4 and IPv6 addresses for localhost to perform test")
}

opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Host = orgAddrs[0]
opts.Port = TEST_PORT
s1 := RunServerWithOptions(&opts)
Expand Down
4 changes: 2 additions & 2 deletions test/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"testing"
"time"

"github.com/nats-io/gnatsd/server"
"github.com/nats-io/gnatsd/test"
"github.com/nats-io/go-nats"
"github.com/nats-io/nats-server/server"
"github.com/nats-io/nats-server/test"
)

func TestAuth(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"testing"
"time"

"github.com/nats-io/gnatsd/server"
"github.com/nats-io/gnatsd/test"
"github.com/nats-io/go-nats"
"github.com/nats-io/nats-server/server"
"github.com/nats-io/nats-server/test"
)

var testServers = []string{
Expand Down
4 changes: 2 additions & 2 deletions test/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"testing"
"time"

"github.com/nats-io/gnatsd/server"
"github.com/nats-io/gnatsd/test"
"github.com/nats-io/go-nats"
"github.com/nats-io/nats-server/server"
"github.com/nats-io/nats-server/test"
)

func TestDefaultConnection(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions test/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"strings"
"time"

"github.com/nats-io/gnatsd/server"
"github.com/nats-io/go-nats"
"github.com/nats-io/nats-server/server"

gnatsd "github.com/nats-io/gnatsd/test"
natsserver "github.com/nats-io/nats-server/test"
)

// So that we can pass tests and benchmarks...
Expand Down Expand Up @@ -78,7 +78,7 @@ func NewDefaultConnection(t tLogger) *nats.Conn {

// NewConnection forms connection on a given port.
func NewConnection(t tLogger, port int) *nats.Conn {
url := fmt.Sprintf("nats://localhost:%d", port)
url := fmt.Sprintf("nats://127.0.0.1:%d", port)
nc, err := nats.Connect(url)
if err != nil {
t.Fatalf("Failed to create default connection: %v\n", err)
Expand All @@ -97,7 +97,7 @@ func NewEConn(t tLogger) *nats.EncodedConn {
}

////////////////////////////////////////////////////////////////////////////////
// Running gnatsd server in separate Go routines
// Running nats server in separate Go routines
////////////////////////////////////////////////////////////////////////////////

// RunDefaultServer will run a server on the default port.
Expand All @@ -107,17 +107,17 @@ func RunDefaultServer() *server.Server {

// RunServerOnPort will run a server on the given port.
func RunServerOnPort(port int) *server.Server {
opts := gnatsd.DefaultTestOptions
opts := natsserver.DefaultTestOptions
opts.Port = port
return RunServerWithOptions(opts)
}

// RunServerWithOptions will run a server with the given options.
func RunServerWithOptions(opts server.Options) *server.Server {
return gnatsd.RunServer(&opts)
return natsserver.RunServer(&opts)
}

// RunServerWithConfig will run a server with the given configuration file.
func RunServerWithConfig(configFile string) (*server.Server, *server.Options) {
return gnatsd.RunServerWithConfig(configFile)
return natsserver.RunServerWithConfig(configFile)
}
2 changes: 1 addition & 1 deletion test/reconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"
"time"

"github.com/nats-io/gnatsd/server"
"github.com/nats-io/go-nats"
"github.com/nats-io/nats-server/server"
)

func startReconnectServer(t *testing.T) *server.Server {
Expand Down

0 comments on commit d15e194

Please sign in to comment.