Skip to content

Commit

Permalink
query client interface and simple implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Feb 19, 2024
1 parent 9ca8650 commit bc65e89
Show file tree
Hide file tree
Showing 66 changed files with 6,301 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
fail-fast: false
matrix:
go-version: [1.21.x, 1.22.x]
ydb-version: [22.5, 23.1, 23.2, 23.3]
ydb-version: [22.5, 23.1, 23.2, 23.3, 24.1]
services:
ydb:
image: cr.yandex/yc/yandex-docker-local-ydb:${{ matrix.ydb-version }}
Expand Down
4 changes: 4 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/ydb-platform/ydb-go-sdk/v3/coordination"
"github.com/ydb-platform/ydb-go-sdk/v3/discovery"
"github.com/ydb-platform/ydb-go-sdk/v3/query"
"github.com/ydb-platform/ydb-go-sdk/v3/ratelimiter"
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
"github.com/ydb-platform/ydb-go-sdk/v3/scripting"
Expand Down Expand Up @@ -34,6 +35,9 @@ type Connection interface {
// Table returns table client
Table() table.Client

// Query returns query client
Query() query.Client

// Scheme returns scheme client
Scheme() scheme.Client

Expand Down
28 changes: 28 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
discoveryConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/discovery/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/dsn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/endpoint"
internalQuery "github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
queryConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/query/config"
internalRatelimiter "github.com/ydb-platform/ydb-go-sdk/v3/internal/ratelimiter"
ratelimiterConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/ratelimiter/config"
internalScheme "github.com/ydb-platform/ydb-go-sdk/v3/internal/scheme"
Expand All @@ -35,6 +37,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
"github.com/ydb-platform/ydb-go-sdk/v3/log"
"github.com/ydb-platform/ydb-go-sdk/v3/query"
"github.com/ydb-platform/ydb-go-sdk/v3/ratelimiter"
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
"github.com/ydb-platform/ydb-go-sdk/v3/scripting"
Expand Down Expand Up @@ -68,6 +71,9 @@ type Driver struct { //nolint:maligned
table *internalTable.Client
tableOptions []tableConfig.Option

query *internalQuery.Client
queryOptions []queryConfig.Option

scripting *internalScripting.Client
scriptingOptions []scriptingConfig.Option

Expand Down Expand Up @@ -141,6 +147,7 @@ func (d *Driver) Close(ctx context.Context) (finalErr error) {
d.scheme.Close,
d.scripting.Close,
d.table.Close,
d.query.Close,
d.topic.Close,
d.balancer.Close,
d.pool.Release,
Expand Down Expand Up @@ -180,6 +187,11 @@ func (d *Driver) Table() table.Client {
return d.table
}

// Query returns query client
func (d *Driver) Query() query.Client {
return d.query
}

// Scheme returns scheme client
func (d *Driver) Scheme() scheme.Client {
return d.scheme
Expand Down Expand Up @@ -399,6 +411,22 @@ func (d *Driver) connect(ctx context.Context) (err error) {
return xerrors.WithStackTrace(err)
}

d.query, err = internalQuery.New(ctx,
d.balancer,
queryConfig.New(
append(
// prepend common params from root config
[]queryConfig.Option{
queryConfig.With(d.config.Common),
},
d.queryOptions...,
)...,
),
)
if err != nil {
return xerrors.WithStackTrace(err)
}

d.scheme, err = internalScheme.New(ctx,
d.balancer,
schemeConfig.New(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
require (
github.com/rekby/fixenv v0.6.1
github.com/stretchr/testify v1.7.1
go.uber.org/mock v0.3.1-0.20231011042131-892b665398ec // indirect
go.uber.org/mock v0.4.0 // indirect
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/mock v0.3.1-0.20231011042131-892b665398ec h1:aB0WVMCyiVcqL1yMRLM4htiFlMvgdOml97GYnw9su5Q=
go.uber.org/mock v0.3.1-0.20231011042131-892b665398ec/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand Down
Loading

0 comments on commit bc65e89

Please sign in to comment.