Skip to content

Commit 8556170

Browse files
author
Dimy Jeannot
committed
fix: removing the nats server name random digits. Needs to be predictable when in cluster mode
1 parent e179b70 commit 8556170

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

go/oeco-sdk/v2beta/bindings/nats/binding.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package natsnodev1
33
import (
44
"context"
55
"fmt"
6-
"math/rand"
76
"net/url"
87
"strconv"
98
"strings"
@@ -76,14 +75,14 @@ func (b *Binding) Bind(_ context.Context, bindings *sdkv2betalib.Bindings) *sdkv
7675
panic("Please provide Nats username and password; This allows for connecting to the NATS server from the NATS client")
7776
}
7877

79-
r := rand.New(rand.NewSource(time.Now().UnixNano()))
78+
// r := rand.New(rand.NewSource(time.Now().UnixNano()))
8079

8180
systemAccount := natsd.NewAccount(natsd.DEFAULT_SYSTEM_ACCOUNT)
8281
connectorAccount := natsd.NewAccount(DEFAULT_CONNECTOR_ACCOUNT)
8382

8483
options := natsd.Options{
8584
// Standard client options
86-
ServerName: b.configuration.Natsd.ServerName + "-" + fmt.Sprintf("%03d", r.Intn(900)+100),
85+
ServerName: b.configuration.Natsd.ServerName,
8786
Host: b.configuration.Natsd.Host,
8887
Port: b.configuration.Natsd.Port,
8988
HTTPPort: b.configuration.Natsd.HTTPPort,
@@ -129,6 +128,7 @@ func (b *Binding) Bind(_ context.Context, bindings *sdkv2betalib.Bindings) *sdkv
129128
Port: b.configuration.Natsd.Cluster.Port,
130129
Name: b.configuration.Natsd.Cluster.Name,
131130
ConnectRetries: 3,
131+
ConnectBackoff: true,
132132
PoolSize: b.configuration.Natsd.Replicas,
133133
Compression: natsd.CompressionOpts{
134134
Mode: "s2_auto",

0 commit comments

Comments
 (0)