Skip to content

Commit 53e1ff9

Browse files
authored
Merge pull request #133 from ydb-platform/revert-grpc-client-conn-interface
revert grpc.ClientConnInterface API to ydb.Connection
2 parents 5402b7f + 5a82c3e commit 53e1ff9

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 3.11.4
22
* Refactored `internal/cluster.Cluster` (add option for notify about external lock, lock cluster for update cluster endpoints)
3+
* Reverted `grpc.ClientConnInterface` API to `ydb.Connection`
34

45
## 3.11.3
56
* Replaced in `table/types/compare_test.go` checking error by error message to checking with `errors.Is()`

connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
type Connection interface {
3636
closer.Closer
3737
db.ConnectionInfo
38+
grpc.ClientConnInterface
3839

3940
// Table returns table client with options from Connection instance.
4041
// Options provide options replacement for requested table client

proxy.go

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package ydb
33
import (
44
"context"
55

6+
"google.golang.org/grpc"
7+
68
"github.com/ydb-platform/ydb-go-sdk/v3/coordination"
79
"github.com/ydb-platform/ydb-go-sdk/v3/discovery"
810
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
@@ -15,9 +17,9 @@ import (
1517
)
1618

1719
type proxyConnection struct {
18-
endpoint string
19-
secure bool
20-
meta meta.Meta
20+
connection Connection
21+
22+
meta meta.Meta
2123

2224
table table.Client
2325
scripting scripting.Client
@@ -27,18 +29,47 @@ type proxyConnection struct {
2729
ratelimiter ratelimiter.Client
2830
}
2931

30-
func newProxy(c Connection, meta meta.Meta) *proxyConnection {
32+
func (c *proxyConnection) Invoke(
33+
ctx context.Context,
34+
method string,
35+
args interface{},
36+
reply interface{},
37+
opts ...grpc.CallOption,
38+
) error {
39+
return c.connection.Invoke(
40+
ctx,
41+
method,
42+
args,
43+
reply,
44+
opts...,
45+
)
46+
}
47+
48+
func (c *proxyConnection) NewStream(
49+
ctx context.Context,
50+
desc *grpc.StreamDesc,
51+
method string,
52+
opts ...grpc.CallOption,
53+
) (grpc.ClientStream, error) {
54+
return c.connection.NewStream(
55+
ctx,
56+
desc,
57+
method,
58+
opts...,
59+
)
60+
}
61+
62+
func newProxy(connection Connection, meta meta.Meta) *proxyConnection {
3163
return &proxyConnection{
32-
endpoint: c.Endpoint(),
33-
secure: c.Secure(),
34-
meta: meta,
35-
36-
table: proxy.Table(c.Table(), meta),
37-
scripting: proxy.Scripting(c.Scripting(), meta),
38-
scheme: proxy.Scheme(c.Scheme(), meta),
39-
discovery: proxy.Discovery(c.Discovery(), meta),
40-
coordination: proxy.Coordination(c.Coordination(), meta),
41-
ratelimiter: proxy.Ratelimiter(c.Ratelimiter(), meta),
64+
connection: connection,
65+
meta: meta,
66+
67+
table: proxy.Table(connection.Table(), meta),
68+
scripting: proxy.Scripting(connection.Scripting(), meta),
69+
scheme: proxy.Scheme(connection.Scheme(), meta),
70+
discovery: proxy.Discovery(connection.Discovery(), meta),
71+
coordination: proxy.Coordination(connection.Coordination(), meta),
72+
ratelimiter: proxy.Ratelimiter(connection.Ratelimiter(), meta),
4273
}
4374
}
4475

@@ -66,15 +97,15 @@ func (c *proxyConnection) Close(ctx context.Context) error {
6697
}
6798

6899
func (c *proxyConnection) Endpoint() string {
69-
return c.endpoint
100+
return c.connection.Endpoint()
70101
}
71102

72103
func (c *proxyConnection) Name() string {
73104
return c.meta.Database()
74105
}
75106

76107
func (c *proxyConnection) Secure() bool {
77-
return c.secure
108+
return c.connection.Secure()
78109
}
79110

80111
func (c *proxyConnection) Table(opts ...CustomOption) table.Client {

0 commit comments

Comments
 (0)