@@ -3,6 +3,7 @@ package ydbgoquery
3
3
import (
4
4
"context"
5
5
"errors"
6
+ "strings"
6
7
"time"
7
8
8
9
"github.com/adwski/ydb-go-query/internal/logger"
@@ -23,9 +24,10 @@ import (
23
24
)
24
25
25
26
const (
26
- defaultSessionCreateTimeout = 3 * time .Second
27
- defaultQueryTimeout = 5 * time .Minute
28
- defaultSessionPoolSize = 10
27
+ defaultSessionCreateTimeout = 3 * time .Second
28
+ defaultQueryTimeout = 5 * time .Minute
29
+ defaultSessionPoolSize = 10
30
+ defaultConnectionsPerEndpoint = 2
29
31
)
30
32
31
33
var (
@@ -43,10 +45,14 @@ type (
43
45
DB string
44
46
InitialNodes []string
45
47
48
+ locationPreference []string
49
+
46
50
poolSize uint
47
51
poolReadyHi uint
48
52
poolReadyLo uint
49
53
54
+ connectionsPerEndpoint int
55
+
50
56
sessionCreateTimeout time.Duration
51
57
queryTimeout time.Duration
52
58
}
@@ -58,6 +64,7 @@ func (cfg *Config) setDefaults() {
58
64
cfg .sessionCreateTimeout = defaultSessionCreateTimeout
59
65
cfg .queryTimeout = defaultQueryTimeout
60
66
cfg .poolSize = defaultSessionPoolSize
67
+ cfg .connectionsPerEndpoint = defaultConnectionsPerEndpoint
61
68
cfg .transportCredentials = transportCreds .Insecure ()
62
69
cfg .txSettings = txsettings .SerializableReadWrite ()
63
70
}
@@ -123,6 +130,27 @@ func WithSessionPoolReadyThresholds(high, low uint) Option {
123
130
}
124
131
}
125
132
133
+ func WithLocationPreference (pref string ) Option {
134
+ return func (ctx context.Context , cfg * Config ) error {
135
+ cfg .locationPreference = strings .Split (pref , "," )
136
+ for idx := range cfg .locationPreference {
137
+ cfg .locationPreference [idx ] = strings .TrimSpace (cfg .locationPreference [idx ])
138
+ }
139
+
140
+ return nil
141
+ }
142
+ }
143
+
144
+ func WithConnectionsPerEndpoint (connections int ) Option {
145
+ return func (ctx context.Context , cfg * Config ) error {
146
+ if connections > 0 {
147
+ cfg .connectionsPerEndpoint = connections
148
+ }
149
+
150
+ return nil
151
+ }
152
+ }
153
+
126
154
func withTransportSecurity (credentials credentials.TransportCredentials ) Option {
127
155
return func (ctx context.Context , cfg * Config ) error {
128
156
cfg .transportCredentials = credentials
0 commit comments