Skip to content

Commit

Permalink
rename internal/connector to internal/xsql
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Dec 10, 2024
1 parent e52398c commit 46b1007
Show file tree
Hide file tree
Showing 40 changed files with 117 additions and 117 deletions.
4 changes: 2 additions & 2 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/discovery"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
internalCoordination "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination"
coordinationConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
Expand All @@ -37,6 +36,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/topic/topicclientinternal"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"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/operation"
Expand Down Expand Up @@ -93,7 +93,7 @@ type (
topic *xsync.Once[*topicclientinternal.Client]
topicOptions []topicoptions.TopicOption

databaseSQLOptions []connector.Option
databaseSQLOptions []xsql.Option

pool *conn.Pool

Expand Down
20 changes: 10 additions & 10 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/balancers"
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
tableSql "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/dsn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
tableSql "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/table/conn"
)

const tablePathPrefixTransformer = "table_path_prefix"
Expand Down Expand Up @@ -64,41 +64,41 @@ func parseConnectionString(dataSourceName string) (opts []Option, _ error) {
if mode == tableSql.UnknownQueryMode {
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
}
opts = append(opts, withConnectorOptions(connector.WithDefaultQueryMode(mode)))
opts = append(opts, withConnectorOptions(xsql.WithDefaultQueryMode(mode)))
} else if queryMode := info.Params.Get("query_mode"); queryMode != "" {
mode := tableSql.QueryModeFromString(queryMode)
if mode == tableSql.UnknownQueryMode {
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
}
opts = append(opts, withConnectorOptions(connector.WithDefaultQueryMode(mode)))
opts = append(opts, withConnectorOptions(xsql.WithDefaultQueryMode(mode)))
}
if fakeTx := info.Params.Get("go_fake_tx"); fakeTx != "" {
for _, queryMode := range strings.Split(fakeTx, ",") {
mode := tableSql.QueryModeFromString(queryMode)
if mode == tableSql.UnknownQueryMode {
return nil, xerrors.WithStackTrace(fmt.Errorf("unknown query mode: %s", queryMode))
}
opts = append(opts, withConnectorOptions(connector.WithFakeTx(mode)))
opts = append(opts, withConnectorOptions(xsql.WithFakeTx(mode)))
}
}
if info.Params.Has("go_query_bind") {
var binders []connector.Option
var binders []xsql.Option
queryTransformers := strings.Split(info.Params.Get("go_query_bind"), ",")
for _, transformer := range queryTransformers {
switch transformer {
case "declare":
binders = append(binders, connector.WithQueryBind(bind.AutoDeclare{}))
binders = append(binders, xsql.WithQueryBind(bind.AutoDeclare{}))
case "positional":
binders = append(binders, connector.WithQueryBind(bind.PositionalArgs{}))
binders = append(binders, xsql.WithQueryBind(bind.PositionalArgs{}))
case "numeric":
binders = append(binders, connector.WithQueryBind(bind.NumericArgs{}))
binders = append(binders, xsql.WithQueryBind(bind.NumericArgs{}))
default:
if strings.HasPrefix(transformer, tablePathPrefixTransformer) {
prefix, err := extractTablePathPrefixFromBinderName(transformer)
if err != nil {
return nil, xerrors.WithStackTrace(err)
}
binders = append(binders, connector.WithQueryBind(bind.TablePathPrefix(prefix)))
binders = append(binders, xsql.WithQueryBind(bind.TablePathPrefix(prefix)))
} else {
return nil, xerrors.WithStackTrace(
fmt.Errorf("unknown query rewriter: %s", transformer),
Expand Down
68 changes: 34 additions & 34 deletions dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/ydb-platform/ydb-go-sdk/v3/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/query/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/query/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/table/conn"
)

func TestParse(t *testing.T) {
newConnector := func(opts ...connector.Option) *connector.Connector {
c := &connector.Connector{}
newConnector := func(opts ...xsql.Option) *xsql.Connector {
c := &xsql.Connector{}
for _, opt := range opts {
if opt != nil {
if err := opt.Apply(c); err != nil {
Expand All @@ -40,7 +40,7 @@ func TestParse(t *testing.T) {
for _, tt := range []struct {
dsn string
opts []config.Option
connectorOpts []connector.Option
connectorOpts []xsql.Option
err error
}{
{
Expand Down Expand Up @@ -70,8 +70,8 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
},
err: nil,
},
Expand All @@ -82,9 +82,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
},
err: nil,
},
Expand All @@ -95,10 +95,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.NumericArgs{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.NumericArgs{}),
},
err: nil,
},
Expand All @@ -109,10 +109,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.PositionalArgs{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.PositionalArgs{}),
},
err: nil,
},
Expand All @@ -123,10 +123,10 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.AutoDeclare{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.AutoDeclare{}),
},
err: nil,
},
Expand All @@ -137,9 +137,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
},
err: nil,
},
Expand All @@ -150,11 +150,11 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithDefaultQueryMode(conn.ScriptingQueryMode),
connector.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
connector.WithQueryBind(bind.PositionalArgs{}),
connector.WithQueryBind(bind.AutoDeclare{}),
connectorOpts: []xsql.Option{
xsql.WithDefaultQueryMode(conn.ScriptingQueryMode),
xsql.WithQueryBind(bind.TablePathPrefix("path/to/tables")),
xsql.WithQueryBind(bind.PositionalArgs{}),
xsql.WithQueryBind(bind.AutoDeclare{}),
},
err: nil,
},
Expand All @@ -165,9 +165,9 @@ func TestParse(t *testing.T) {
config.WithEndpoint("localhost:2135"),
config.WithDatabase("/local"),
},
connectorOpts: []connector.Option{
connector.WithFakeTx(conn.ScriptingQueryMode),
connector.WithFakeTx(conn.SchemeQueryMode),
connectorOpts: []xsql.Option{
xsql.WithFakeTx(conn.ScriptingQueryMode),
xsql.WithFakeTx(conn.SchemeQueryMode),
},
err: nil,
},
Expand Down
8 changes: 4 additions & 4 deletions internal/connector/conn.go → internal/xsql/conn.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import (
"context"
Expand All @@ -10,14 +10,14 @@ import (
"strings"
"time"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/scheme/helpers"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
internalTable "github.com/ydb-platform/ydb-go-sdk/v3/internal/table"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/table/config"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xslices"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
Expand Down Expand Up @@ -124,7 +124,7 @@ func (c *conn) Prepare(string) (driver.Stmt, error) {

func (c *conn) PrepareContext(ctx context.Context, sql string) (_ driver.Stmt, finalErr error) {
onDone := trace.DatabaseSQLOnConnPrepare(c.connector.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/connector.(*conn).PrepareContext"),
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn).PrepareContext"),
sql,
)
defer func() {
Expand Down Expand Up @@ -393,7 +393,7 @@ func (c *conn) IsColumnExists(ctx context.Context, tableName, columnName string)
func (c *conn) IsTableExists(ctx context.Context, tableName string) (tableExists bool, finalErr error) {
tableName = c.normalizePath(tableName)
onDone := trace.DatabaseSQLOnConnIsTableExists(c.connector.trace, &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/connector.(*conn).IsTableExists"),
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn).IsTableExists"),
tableName,
)
defer func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import "context"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import (
"context"
Expand All @@ -12,11 +12,11 @@ import (
"google.golang.org/grpc"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
conn3 "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/query/conn"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
conn3 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/query/conn"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
Expand Down
2 changes: 1 addition & 1 deletion internal/connector/context.go → internal/xsql/context.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import "context"

Expand Down
2 changes: 1 addition & 1 deletion internal/connector/errors.go → internal/xsql/errors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import (
"database/sql/driver"
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions internal/connector/options.go → internal/xsql/options.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package connector
package xsql

import (
"time"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
querySql "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/query/conn"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/table/conn"
querySql "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/query/conn"
conn2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/table/conn"
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"database/sql/driver"
"sync/atomic"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query/options"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query/session"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stats"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/iface"
)

type resultNoRows struct{}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"database/sql/driver"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/query/conn/isolation"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query/options"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/query/conn/isolation"
"github.com/ydb-platform/ydb-go-sdk/v3/query"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/connector/stmt.go → internal/xsql/stmt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package connector
package xsql

import (
"context"
Expand Down Expand Up @@ -28,7 +28,7 @@ var (

func (stmt *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (_ driver.Rows, finalErr error) {
onDone := trace.DatabaseSQLOnStmtQuery(stmt.conn.connector.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/connector.(*stmt).QueryContext"),
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*stmt).QueryContext"),
stmt.ctx, stmt.sql,
)
defer func() {
Expand All @@ -49,7 +49,7 @@ func (stmt *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (_

func (stmt *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (_ driver.Result, finalErr error) {
onDone := trace.DatabaseSQLOnStmtExec(stmt.conn.connector.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/connector.(*stmt).ExecContext"),
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*stmt).ExecContext"),
stmt.ctx, stmt.sql,
)
defer func() {
Expand All @@ -76,7 +76,7 @@ func (stmt *stmt) Close() (finalErr error) {
var (
ctx = stmt.ctx
onDone = trace.DatabaseSQLOnStmtClose(stmt.conn.connector.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/connector.(*stmt).Close"),
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*stmt).Close"),
)
)
defer func() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"sync/atomic"
"time"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/connector/table/conn/badconn"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/iface"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/table/conn/badconn"
"github.com/ydb-platform/ydb-go-sdk/v3/scripting"
"github.com/ydb-platform/ydb-go-sdk/v3/table"
"github.com/ydb-platform/ydb-go-sdk/v3/table/options"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 46b1007

Please sign in to comment.