File tree 2 files changed +26
-5
lines changed
2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 79
79
ErrStaleConnection = errors .New ("nats: " + STALE_CONNECTION )
80
80
)
81
81
82
+ // GetDefaultOptions returns default configuration options for the client.
82
83
func GetDefaultOptions () Options {
83
- opts := Options {
84
+ return Options {
84
85
AllowReconnect : true ,
85
86
MaxReconnect : DefaultMaxReconnect ,
86
87
ReconnectWait : DefaultReconnectWait ,
@@ -89,11 +90,7 @@ func GetDefaultOptions() Options {
89
90
MaxPingsOut : DefaultMaxPingOut ,
90
91
SubChanLen : DefaultMaxChanLen ,
91
92
ReconnectBufSize : DefaultReconnectBufSize ,
92
- Dialer : & net.Dialer {
93
- Timeout : DefaultTimeout ,
94
- },
95
93
}
96
- return opts
97
94
}
98
95
99
96
// DEPRECATED: Use GetDefaultOptions() instead.
Original file line number Diff line number Diff line change @@ -1312,6 +1312,30 @@ func TestUseCustomDialer(t *testing.T) {
1312
1312
}
1313
1313
}
1314
1314
1315
+ func TestDefaultOptionsDialer (t * testing.T ) {
1316
+ s := RunDefaultServer ()
1317
+ defer s .Shutdown ()
1318
+
1319
+ opts1 := nats .DefaultOptions
1320
+ opts2 := nats .DefaultOptions
1321
+
1322
+ nc1 , err := opts1 .Connect ()
1323
+ if err != nil {
1324
+ t .Fatalf ("Unexpected error on connect: %v" , err )
1325
+ }
1326
+ defer nc1 .Close ()
1327
+
1328
+ nc2 , err := opts2 .Connect ()
1329
+ if err != nil {
1330
+ t .Fatalf ("Unexpected error on connect: %v" , err )
1331
+ }
1332
+ defer nc2 .Close ()
1333
+
1334
+ if nc1 .Opts .Dialer == nc2 .Opts .Dialer {
1335
+ t .Fatalf ("Expected each connection to have its own dialer" )
1336
+ }
1337
+ }
1338
+
1315
1339
func TestCustomFlusherTimeout (t * testing.T ) {
1316
1340
s := RunDefaultServer ()
1317
1341
defer s .Shutdown ()
You can’t perform that action at this time.
0 commit comments