Skip to content

Commit 91383d8

Browse files
authored
Merge pull request #376 from ydb-platform/session-balancing
* Marked sessions which creates from `database/sql` driver as support…
2 parents bbace28 + eb92d08 commit 91383d8

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Marked sessions which creates from `database/sql` driver as supported server-side session balancing
2+
13
## v3.37.7
24
* Changed type of truncated result error from `StreamExecuteScanQuery` to retryable error
35
* Added closing sessions if node removed from discovery results

internal/xerrors/operation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (e *operationError) Code() int32 {
2424
}
2525

2626
func (e *operationError) Name() string {
27-
return e.code.String()
27+
return "operation/" + e.code.String()
2828
}
2929

3030
type operationStatus interface {

internal/xerrors/retryable.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ func (e *retryableError) Code() int32 {
1919
}
2020

2121
func (e *retryableError) Name() string {
22-
if e.name != "" {
23-
return e.name
24-
}
25-
return "CUSTOM"
22+
return "retryable/" + e.name
2623
}
2724

2825
func (e *retryableError) OperationStatus() operation.Status {
@@ -67,7 +64,8 @@ func WithDeleteSession() RetryableErrorOption {
6764

6865
func Retryable(err error, opts ...RetryableErrorOption) error {
6966
re := &retryableError{
70-
err: err,
67+
err: err,
68+
name: "CUSTOM",
7169
}
7270
for _, o := range opts {
7371
o(re)

internal/xerrors/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (e *transportError) Code() int32 {
3030
}
3131

3232
func (e *transportError) Name() string {
33-
return e.code.String()
33+
return "transport/" + e.code.String()
3434
}
3535

3636
type teOpt func(te *transportError)

internal/xsql/connector.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"database/sql/driver"
66
"io"
77

8+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/meta"
89
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
910
"github.com/ydb-platform/ydb-go-sdk/v3/scripting"
1011
"github.com/ydb-platform/ydb-go-sdk/v3/table"
@@ -115,7 +116,11 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, err error) {
115116
defer func() {
116117
onDone(err)
117118
}()
118-
s, err := c.connection.Table().CreateSession(ctx)
119+
s, err := c.connection.Table().CreateSession(
120+
meta.WithAllowFeatures(ctx,
121+
meta.HintSessionBalancer,
122+
),
123+
)
119124
if err != nil {
120125
return nil, xerrors.WithStackTrace(err)
121126
}

0 commit comments

Comments
 (0)