Skip to content

Commit 9474655

Browse files
committed
fixed linter issues
1 parent a4f324c commit 9474655

File tree

12 files changed

+35
-47
lines changed

12 files changed

+35
-47
lines changed

internal/query/conn/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type (
2626
Rollback() error
2727
}
2828
conn struct {
29-
ctx context.Context
29+
ctx context.Context //nolint:containedctx
3030
parent Parent
3131
trace *trace.DatabaseSQL
3232
traceRetry *trace.Retry

internal/query/conn/errors.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ package conn
22

33
import "errors"
44

5-
var (
6-
errConnClosedEarly = errors.New("conn closed early")
7-
)
5+
var errConnClosedEarly = errors.New("conn closed early")

internal/table/conn/conn.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var (
9999
)
100100

101101
func New(ctx context.Context, parent Parent, opts ...Option) (*conn, error) {
102-
s, err := parent.Table().CreateSession(ctx)
102+
s, err := parent.Table().CreateSession(ctx) //nolint:staticcheck
103103
if err != nil {
104104
return nil, xerrors.WithStackTrace(err)
105105
}
@@ -471,12 +471,11 @@ func (c *conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (_ drive
471471
}()
472472

473473
if c.currentTx != nil {
474-
return nil, xerrors.WithStackTrace(
475-
xerrors.Retryable(
476-
&ConnAlreadyHaveTxError{
477-
currentTx: c.currentTx.ID(),
478-
},
479-
xerrors.InvalidObject(),
474+
return nil, badconn.Map(
475+
xerrors.WithStackTrace(
476+
fmt.Errorf("broken conn state: conn=%q already have current tx=%q",
477+
c.ID(), c.currentTx.ID(),
478+
),
480479
),
481480
)
482481
}

internal/table/conn/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ var (
1414
errNotReadyConn = xerrors.Retryable(errors.New("conn not ready"), xerrors.InvalidObject())
1515
)
1616

17-
type ConnAlreadyHaveTxError struct {
17+
type AlreadyHaveTxError struct {
1818
currentTx string
1919
}
2020

21-
func (err *ConnAlreadyHaveTxError) Error() string {
21+
func (err *AlreadyHaveTxError) Error() string {
2222
return "conn already have an open currentTx: " + err.currentTx
2323
}
2424

25-
func (err *ConnAlreadyHaveTxError) As(target interface{}) bool {
25+
func (err *AlreadyHaveTxError) As(target interface{}) bool {
2626
switch t := target.(type) {
27-
case *ConnAlreadyHaveTxError:
27+
case *AlreadyHaveTxError:
2828
t.currentTx = err.currentTx
2929

3030
return true

internal/table/conn/tx.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ var (
3030
)
3131

3232
func beginTx(ctx context.Context, c *conn, txOptions driver.TxOptions) (currentTx, error) {
33-
if c.currentTx != nil {
34-
return nil, badconn.Map(
35-
xerrors.WithStackTrace(
36-
fmt.Errorf("broken conn state: conn=%q already have current tx=%q",
37-
c.ID(), c.currentTx.ID(),
38-
),
39-
),
40-
)
41-
}
4233
txc, err := isolation.ToYDB(txOptions)
4334
if err != nil {
4435
return nil, xerrors.WithStackTrace(err)
@@ -47,14 +38,13 @@ func beginTx(ctx context.Context, c *conn, txOptions driver.TxOptions) (currentT
4738
if err != nil {
4839
return nil, badconn.Map(xerrors.WithStackTrace(err))
4940
}
41+
5042
return &transaction{
5143
Identifier: tx.ID(nativeTx.ID()),
5244
conn: c,
5345
ctx: ctx,
5446
tx: nativeTx,
5547
}, nil
56-
57-
return c.currentTx, nil
5848
}
5949

6050
func (tx *transaction) checkTxState() error {

internal/table/conn/tx_fake.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var (
4747
_ tx.Identifier = &txFake{}
4848
)
4949

50-
func beginTxFake(ctx context.Context, c *conn, txOptions driver.TxOptions) (currentTx, error) {
50+
func beginTxFake(ctx context.Context, c *conn, _ driver.TxOptions) (currentTx, error) {
5151
return &txFake{
5252
Identifier: tx.ID("FAKE"),
5353
conn: c,

internal/xsql/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (c *connWrapper) IsColumnExists(ctx context.Context, tableName, columnName
239239

240240
func (c *connWrapper) IsTableExists(ctx context.Context, tableName string) (tableExists bool, finalErr error) {
241241
tableName = c.normalizePath(tableName)
242-
onDone := trace.DatabaseSQLOnConnIsTableExists(c.connector.traceSql, &ctx,
242+
onDone := trace.DatabaseSQLOnConnIsTableExists(c.connector.trace, &ctx,
243243
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*connWrapper).IsTableExists"),
244244
tableName,
245245
)

internal/xsql/connector.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type (
4646
idleThreshold time.Duration
4747
conns xsync.Map[uuid.UUID, *connWrapper]
4848
done chan struct{}
49-
traceSql *trace.DatabaseSQL
49+
trace *trace.DatabaseSQL
5050
traceRetry *trace.Retry
5151
retryBudget budget.Budget
5252
}
@@ -80,18 +80,17 @@ func (c *Connector) Scheme() scheme.Client {
8080
}
8181

8282
const (
83-
queryProcessor_QueryService = iota + 1
84-
queryProcessor_TableService
83+
QUERY_SERVICE = iota + 1 //nolint:revive,stylecheck
84+
TABLE_SERVICE //nolint:revive,stylecheck
8585
)
8686

8787
func (c *Connector) Open(name string) (driver.Conn, error) {
88-
//TODO implement me
89-
panic("implement me")
88+
return nil, xerrors.WithStackTrace(driver.ErrSkip)
9089
}
9190

9291
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
9392
switch c.queryProcessor {
94-
case queryProcessor_QueryService:
93+
case QUERY_SERVICE:
9594
id := uuid.New()
9695
cc, err := querySql.New(ctx, c, append(
9796
c.queryOpts,
@@ -114,7 +113,7 @@ func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
114113

115114
return conn, nil
116115

117-
case queryProcessor_TableService:
116+
case TABLE_SERVICE:
118117
id := uuid.New()
119118
cc, err := tableSql.New(ctx, c, append(
120119
c.tableOpts,
@@ -168,10 +167,10 @@ func Open(parent ydbDriver, balancer grpc.ClientConnInterface, opts ...Option) (
168167
c := &Connector{
169168
parent: parent,
170169
balancer: balancer,
171-
queryProcessor: queryProcessor_TableService,
170+
queryProcessor: TABLE_SERVICE,
172171
clock: clockwork.NewRealClock(),
173172
done: make(chan struct{}),
174-
traceSql: &trace.DatabaseSQL{},
173+
trace: &trace.DatabaseSQL{},
175174
traceRetry: &trace.Retry{},
176175
}
177176

internal/xsql/errors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
var (
99
ErrUnsupported = driver.ErrSkip
10-
errDeprecated = driver.ErrSkip
1110
errAlreadyClosed = errors.New("already closed")
1211
errWrongQueryProcessor = errors.New("wrong query processor")
1312
)

internal/xsql/options.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type (
2222
tableOps []tableSql.Option
2323
queryOpts []querySql.Option
2424
}
25-
traceDatabaseSqlOption struct {
25+
traceDatabaseSQLOption struct {
2626
t *trace.DatabaseSQL
2727
opts []trace.DatabaseSQLComposeOption
2828
}
@@ -81,8 +81,8 @@ func (disableServerBalancerOption) Apply(c *Connector) error {
8181
return nil
8282
}
8383

84-
func (opt traceDatabaseSqlOption) Apply(c *Connector) error {
85-
c.traceSql = c.traceSql.Compose(opt.t, opt.opts...)
84+
func (opt traceDatabaseSQLOption) Apply(c *Connector) error {
85+
c.trace = c.trace.Compose(opt.t, opt.opts...)
8686
c.tableOpts = append(c.tableOpts, tableSql.WithTrace(opt.t, opt.opts...))
8787
c.queryOpts = append(c.queryOpts, querySql.WithTrace(opt.t, opt.opts...))
8888

@@ -100,7 +100,7 @@ func WithTrace(
100100
t *trace.DatabaseSQL, //nolint:gocritic
101101
opts ...trace.DatabaseSQLComposeOption,
102102
) Option {
103-
return traceDatabaseSqlOption{
103+
return traceDatabaseSQLOption{
104104
t: t,
105105
opts: opts,
106106
}
@@ -173,9 +173,9 @@ func WithQueryOptions(opts ...querySql.Option) Option {
173173
}
174174

175175
func OverQueryService() Option {
176-
return queryProcessorOption(queryProcessor_QueryService)
176+
return queryProcessorOption(QUERY_SERVICE)
177177
}
178178

179179
func OverTableService() Option {
180-
return queryProcessorOption(queryProcessor_TableService)
180+
return queryProcessorOption(TABLE_SERVICE)
181181
}

0 commit comments

Comments
 (0)