Skip to content

Commit 8f46514

Browse files
Update nats.go dependency
Signed-off-by: Maurice van Veen <[email protected]>
1 parent b484711 commit 8f46514

9 files changed

+36
-47
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/nats-io/nats-server/v2
22

3-
go 1.22
3+
go 1.22.0
44

55
toolchain go1.22.8
66

@@ -10,7 +10,7 @@ require (
1010
github.com/klauspost/compress v1.17.11
1111
github.com/minio/highwayhash v1.0.3
1212
github.com/nats-io/jwt/v2 v2.7.3
13-
github.com/nats-io/nats.go v1.36.0
13+
github.com/nats-io/nats.go v1.39.0
1414
github.com/nats-io/nkeys v0.4.9
1515
github.com/nats-io/nuid v1.0.1
1616
go.uber.org/automaxprocs v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD
1010
github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
1111
github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE=
1212
github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4=
13-
github.com/nats-io/nats.go v1.36.0 h1:suEUPuWzTSse/XhESwqLxXGuj8vGRuPRoG7MoRN/qyU=
14-
github.com/nats-io/nats.go v1.36.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
13+
github.com/nats-io/nats.go v1.39.0 h1:2/yg2JQjiYYKLwDuBzV0FbB2sIV+eFNkEevlRi4n9lI=
14+
github.com/nats-io/nats.go v1.39.0/go.mod h1:MgRb8oOdigA6cYpEPhXJuRVH6UE/V4jblJ2jQ27IXYM=
1515
github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0=
1616
github.com/nats-io/nkeys v0.4.9/go.mod h1:jcMqs+FLG+W5YO36OX6wFIFcmpdAns+w1Wm6D3I/evE=
1717
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=

server/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,6 +3192,6 @@ func TestClientRejectsNRGSubjects(t *testing.T) {
31923192
require_NoError(t, nc.Publish("$NRG.foo", nil))
31933193
err = require_ChanRead(t, ech, time.Second)
31943194
require_Error(t, err)
3195-
require_True(t, strings.HasPrefix(err.Error(), "nats: Permissions Violation"))
3195+
require_True(t, strings.HasPrefix(err.Error(), "nats: permissions violation"))
31963196
})
31973197
}

server/jetstream_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18697,7 +18697,7 @@ func TestJetStreamDirectGetBySubject(t *testing.T) {
1869718697

1869818698
select {
1869918699
case e := <-errCh:
18700-
if !strings.HasPrefix(e.Error(), "nats: Permissions Violation") {
18700+
if !strings.HasPrefix(e.Error(), "nats: permissions violation") {
1870118701
t.Fatalf("Expected a permissions violation but got %v", e)
1870218702
}
1870318703
case <-time.After(time.Second):

server/jwt_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4281,7 +4281,7 @@ func TestJWTLimits(t *testing.T) {
42814281
t.Run("subs", func(t *testing.T) {
42824282
creds := createUserWithLimit(t, kp, doNotExpire, func(j *jwt.UserPermissionLimits) { j.Subs = 1 })
42834283
c := natsConnect(t, sA.ClientURL(), nats.UserCredentials(creds),
4284-
nats.DisconnectErrHandler(func(conn *nats.Conn, err error) {
4284+
nats.ErrorHandler(func(conn *nats.Conn, s *nats.Subscription, err error) {
42854285
if e := conn.LastError(); e != nil && strings.Contains(e.Error(), "maximum subscriptions exceeded") {
42864286
errChan <- struct{}{}
42874287
}
@@ -4466,7 +4466,7 @@ func TestJWTLimitsTemplate(t *testing.T) {
44664466
t.Run("fail", func(t *testing.T) {
44674467
c := natsConnect(t, sA.ClientURL(), nats.UserCredentials(creds),
44684468
nats.ErrorHandler(func(_ *nats.Conn, _ *nats.Subscription, err error) {
4469-
if strings.Contains(err.Error(), `nats: Permissions Violation for Publish to "foo.othername"`) {
4469+
if strings.Contains(err.Error(), `Permissions Violation for Publish to "foo.othername"`) {
44704470
errChan <- struct{}{}
44714471
}
44724472
}))

server/monitor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ func createClientConnWithUserSubscribeAndPublish(t *testing.T, s *Server, user,
20852085
} else {
20862086
natsURL = fmt.Sprintf("nats://%s:%[email protected]:%d", user, pwd, s.Addr().(*net.TCPAddr).Port)
20872087
}
2088-
client := nats.DefaultOptions
2088+
client := nats.GetDefaultOptions()
20892089
client.Servers = []string{natsURL}
20902090
nc, err := client.Connect()
20912091
if err != nil {
@@ -2114,7 +2114,7 @@ func createClientConnSubscribeAndPublish(t *testing.T, s *Server) *nats.Conn {
21142114
func createClientConnWithName(t *testing.T, name string, s *Server) *nats.Conn {
21152115
natsURI := fmt.Sprintf("nats://127.0.0.1:%d", s.Addr().(*net.TCPAddr).Port)
21162116

2117-
client := nats.DefaultOptions
2117+
client := nats.GetDefaultOptions()
21182118
client.Servers = []string{natsURI}
21192119
client.Name = name
21202120
nc, err := client.Connect()

test/client_cluster_test.go

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package test
1616
import (
1717
"fmt"
1818
"math/rand"
19+
"strconv"
1920
"sync"
2021
"sync/atomic"
2122
"testing"
@@ -129,8 +130,8 @@ func TestServerRestartAndQueueSubs(t *testing.T) {
129130

130131
// Client options
131132
opts := nats.GetDefaultOptions()
132-
opts.Timeout = (5 * time.Second)
133-
opts.ReconnectWait = (20 * time.Millisecond)
133+
opts.Timeout = 5 * time.Second
134+
opts.ReconnectWait = 20 * time.Millisecond
134135
opts.MaxReconnect = 1000
135136
opts.NoRandomize = true
136137

@@ -152,20 +153,17 @@ func TestServerRestartAndQueueSubs(t *testing.T) {
152153

153154
// Create two clients..
154155
opts.Servers = []string{urlA, urlB}
155-
nc1, err := opts.Connect()
156+
c1, err := opts.Connect()
156157
if err != nil {
157-
t.Fatalf("Failed to create connection for nc1: %v\n", err)
158+
t.Fatalf("Failed to create connection for c1: %v\n", err)
158159
}
160+
defer c1.Close()
159161

160162
opts.Servers = []string{urlB, urlA}
161-
nc2, err := opts.Connect()
163+
c2, err := opts.Connect()
162164
if err != nil {
163-
t.Fatalf("Failed to create connection for nc2: %v\n", err)
165+
t.Fatalf("Failed to create connection for c2: %v\n", err)
164166
}
165-
166-
c1, _ := nats.NewEncodedConn(nc1, "json")
167-
defer c1.Close()
168-
c2, _ := nats.NewEncodedConn(nc2, "json")
169167
defer c2.Close()
170168

171169
// Flusher helper function.
@@ -202,9 +200,10 @@ func TestServerRestartAndQueueSubs(t *testing.T) {
202200
subj := "foo.bar"
203201
qgroup := "workers"
204202

205-
cb := func(seqno int) {
203+
cb := func(msg *nats.Msg) {
206204
mu.Lock()
207205
defer mu.Unlock()
206+
seqno, _ := strconv.Atoi(string(msg.Data))
208207
results[seqno] = results[seqno] + 1
209208
}
210209

@@ -222,9 +221,9 @@ func TestServerRestartAndQueueSubs(t *testing.T) {
222221
sendAndCheckMsgs := func(numToSend int) {
223222
for i := 0; i < numToSend; i++ {
224223
if i%2 == 0 {
225-
c1.Publish(subj, i)
224+
c1.Publish(subj, []byte(strconv.Itoa(i)))
226225
} else {
227-
c2.Publish(subj, i)
226+
c2.Publish(subj, []byte(strconv.Itoa(i)))
228227
}
229228
}
230229
// Wait for processing.
@@ -309,8 +308,6 @@ func TestRequestsAcrossRoutes(t *testing.T) {
309308
}
310309
defer nc2.Close()
311310

312-
ec2, _ := nats.NewEncodedConn(nc2, nats.JSON_ENCODER)
313-
314311
response := []byte("I will help you")
315312

316313
// Connect responder to srvA
@@ -320,14 +317,12 @@ func TestRequestsAcrossRoutes(t *testing.T) {
320317
// Make sure the route and the subscription are propagated.
321318
nc1.Flush()
322319

323-
if err := checkExpectedSubs(1, srvA, srvB); err != nil {
320+
if err = checkExpectedSubs(1, srvA, srvB); err != nil {
324321
t.Fatal(err.Error())
325322
}
326323

327-
var resp string
328-
329324
for i := 0; i < 100; i++ {
330-
if err := ec2.Request("foo-req", i, &resp, 250*time.Millisecond); err != nil {
325+
if _, err = nc2.Request("foo-req", []byte(strconv.Itoa(i)), 250*time.Millisecond); err != nil {
331326
t.Fatalf("Received an error on Request test [%d]: %s", i, err)
332327
}
333328
}
@@ -354,9 +349,6 @@ func TestRequestsAcrossRoutesToQueues(t *testing.T) {
354349
}
355350
defer nc2.Close()
356351

357-
ec1, _ := nats.NewEncodedConn(nc1, nats.JSON_ENCODER)
358-
ec2, _ := nats.NewEncodedConn(nc2, nats.JSON_ENCODER)
359-
360352
response := []byte("I will help you")
361353

362354
// Connect one responder to srvA
@@ -371,20 +363,18 @@ func TestRequestsAcrossRoutesToQueues(t *testing.T) {
371363
nc2.Publish(m.Reply, response)
372364
})
373365

374-
if err := checkExpectedSubs(2, srvA, srvB); err != nil {
366+
if err = checkExpectedSubs(2, srvA, srvB); err != nil {
375367
t.Fatal(err.Error())
376368
}
377369

378-
var resp string
379-
380370
for i := 0; i < 100; i++ {
381-
if err := ec2.Request("foo-req", i, &resp, 500*time.Millisecond); err != nil {
371+
if _, err = nc2.Request("foo-req", []byte(strconv.Itoa(i)), 500*time.Millisecond); err != nil {
382372
t.Fatalf("Received an error on Request test [%d]: %s", i, err)
383373
}
384374
}
385375

386376
for i := 0; i < 100; i++ {
387-
if err := ec1.Request("foo-req", i, &resp, 500*time.Millisecond); err != nil {
377+
if _, err = nc1.Request("foo-req", []byte(strconv.Itoa(i)), 500*time.Millisecond); err != nil {
388378
t.Fatalf("Received an error on Request test [%d]: %s", i, err)
389379
}
390380
}

test/fanout_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package test
1818

1919
import (
2020
"fmt"
21+
"strconv"
2122
"sync"
2223
"testing"
2324

@@ -61,11 +62,10 @@ func TestNoRaceHighFanoutOrdering(t *testing.T) {
6162
t.Fatalf("Got an error %v for %+v\n", s, err)
6263
})
6364

64-
ec, _ := nats.NewEncodedConn(nc, nats.DEFAULT_ENCODER)
65-
6665
for y := 0; y < nsubs; y++ {
6766
expected := 0
68-
ec.Subscribe(subj, func(n int) {
67+
nc.Subscribe(subj, func(msg *nats.Msg) {
68+
n, _ := strconv.Atoi(string(msg.Data))
6969
if n != expected {
7070
t.Fatalf("Expected %d but received %d\n", expected, n)
7171
}
@@ -75,17 +75,16 @@ func TestNoRaceHighFanoutOrdering(t *testing.T) {
7575
}
7676
})
7777
}
78-
ec.Flush()
79-
defer ec.Close()
78+
nc.Flush()
79+
defer nc.Close()
8080
}
8181

8282
nc, _ := nats.Connect(url)
83-
ec, _ := nats.NewEncodedConn(nc, nats.DEFAULT_ENCODER)
8483

8584
for i := 0; i < npubs; i++ {
86-
ec.Publish(subj, i)
85+
nc.Publish(subj, []byte(strconv.Itoa(i)))
8786
}
88-
defer ec.Close()
87+
defer nc.Close()
8988

9089
wg.Wait()
9190
}

test/tls_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestTLSConnection(t *testing.T) {
6666

6767
nc.Publish(subj, []byte("We are Secure!"))
6868
nc.Flush()
69-
nmsgs, _ := sub.QueuedMsgs()
69+
nmsgs, _, _ := sub.Pending()
7070
if nmsgs != 1 {
7171
t.Fatalf("Expected to receive a message over the TLS connection")
7272
}
@@ -1100,7 +1100,7 @@ func TestTLSConnectionCurvePref(t *testing.T) {
11001100

11011101
nc.Publish(subj, []byte("We are Secure!"))
11021102
nc.Flush()
1103-
nmsgs, _ := sub.QueuedMsgs()
1103+
nmsgs, _, _ := sub.Pending()
11041104
if nmsgs != 1 {
11051105
t.Fatalf("Expected to receive a message over the TLS connection")
11061106
}

0 commit comments

Comments
 (0)