Skip to content

Commit 27ef784

Browse files
committed
* Renamed package internal/db to internal/database for exclude collisions with variable name db
1 parent 93f22c5 commit 27ef784

File tree

10 files changed

+47
-45
lines changed

10 files changed

+47
-45
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Renamed package `internal/db` to `internal/database` for exclude collisions with variable name `db`
2+
13
## v3.18.0
24
* Added `go1.18` to test matrix
35
* Added `ydb.WithOperationTimeout` and `ydb.WithOperationCancelAfter` context modifiers

connection.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer/single"
1616
"github.com/ydb-platform/ydb-go-sdk/v3/internal/closer"
1717
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
18-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
18+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
1919
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
2020
"github.com/ydb-platform/ydb-go-sdk/v3/internal/lazy"
2121
"github.com/ydb-platform/ydb-go-sdk/v3/log"
@@ -34,7 +34,7 @@ import (
3434
// Interface and list of clients may be changed in the future
3535
type Connection interface {
3636
closer.Closer
37-
db.Info
37+
database.Info
3838
grpc.ClientConnInterface
3939

4040
// Table returns table client
@@ -86,7 +86,7 @@ type connection struct {
8686
pool conn.Pool
8787

8888
mtx sync.Mutex
89-
db db.Connection
89+
db database.Connection
9090

9191
children map[uint64]Connection
9292
childrenMtx sync.Mutex
@@ -274,7 +274,7 @@ func New(ctx context.Context, opts ...Option) (_ Connection, err error) {
274274
)
275275
}
276276

277-
c.db, err = db.New(
277+
c.db, err = database.New(
278278
ctx,
279279
c.config,
280280
c.pool,

internal/db/connection.go renamed to internal/database/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package db
1+
package database
22

33
import (
44
"google.golang.org/grpc"

internal/db/database.go renamed to internal/database/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package db
1+
package database
22

33
import (
44
"context"

internal/lazy/coordiantion.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import (
77
"github.com/ydb-platform/ydb-go-sdk/v3/coordination"
88
"github.com/ydb-platform/ydb-go-sdk/v3/coordination/config"
99
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination"
10-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
10+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
1111
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
1212
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
1313
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
1414
)
1515

1616
type lazyCoordination struct {
17-
db db.Connection
17+
db database.Connection
1818
options []config.Option
1919
client coordination.Client
2020
m sync.Mutex
2121
}
2222

23-
func Coordination(db db.Connection, options []config.Option) coordination.Client {
23+
func Coordination(db database.Connection, options []config.Option) coordination.Client {
2424
return &lazyCoordination{
2525
db: db,
2626
options: options,

internal/lazy/ratelimiter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"sync"
66

7-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
7+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
88
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
99
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/ratelimiter"
1010
"github.com/ydb-platform/ydb-go-sdk/v3/internal/ratelimiter/options"
@@ -14,13 +14,13 @@ import (
1414
)
1515

1616
type lazyRatelimiter struct {
17-
db db.Connection
17+
db database.Connection
1818
options []config.Option
1919
client ratelimiter.Client
2020
m sync.Mutex
2121
}
2222

23-
func Ratelimiter(db db.Connection, options []config.Option) ratelimiter.Client {
23+
func Ratelimiter(db database.Connection, options []config.Option) ratelimiter.Client {
2424
return &lazyRatelimiter{
2525
db: db,
2626
options: options,

internal/lazy/scheme.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"sync"
66

7-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
7+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
88
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
99
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/scheme"
1010
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
@@ -13,13 +13,13 @@ import (
1313
)
1414

1515
type lazyScheme struct {
16-
db db.Connection
16+
db database.Connection
1717
options []config.Option
1818
client scheme.Client
1919
m sync.Mutex
2020
}
2121

22-
func Scheme(db db.Connection, options []config.Option) scheme.Client {
22+
func Scheme(db database.Connection, options []config.Option) scheme.Client {
2323
return &lazyScheme{
2424
db: db,
2525
options: options,

internal/lazy/scripting.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"sync"
66

7-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
7+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
88
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
99
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/scripting"
1010
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
type lazyScripting struct {
18-
db db.Connection
18+
db database.Connection
1919
options []config.Option
2020
client scripting.Client
2121
m sync.Mutex
@@ -76,7 +76,7 @@ func (s *lazyScripting) Close(ctx context.Context) (err error) {
7676
return nil
7777
}
7878

79-
func Scripting(db db.Connection, options []config.Option) scripting.Client {
79+
func Scripting(db database.Connection, options []config.Option) scripting.Client {
8080
return &lazyScripting{
8181
db: db,
8282
options: options,

internal/lazy/table.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import (
44
"context"
55
"sync"
66

7-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
7+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
88
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
99
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/table"
1010
"github.com/ydb-platform/ydb-go-sdk/v3/table"
1111
"github.com/ydb-platform/ydb-go-sdk/v3/table/config"
1212
)
1313

1414
type lazyTable struct {
15-
db db.Connection
15+
db database.Connection
1616
options []config.Option
1717
client table.Client
1818
m sync.Mutex
1919
}
2020

21-
func Table(db db.Connection, options []config.Option) table.Client {
21+
func Table(db database.Connection, options []config.Option) table.Client {
2222
return &lazyTable{
2323
db: db,
2424
options: options,

testutil/driver.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Operations"
1515

16-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
16+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/database"
1717
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
1818
)
1919

@@ -158,7 +158,7 @@ func getField(name string, src, dst interface{}) bool {
158158
return fn(reflect.ValueOf(src).Elem(), strings.Split(name, ".")...)
159159
}
160160

161-
type database struct {
161+
type cluster struct {
162162
onInvoke func(
163163
ctx context.Context,
164164
method string,
@@ -177,59 +177,59 @@ type database struct {
177177
) error
178178
}
179179

180-
func (db *database) Invoke(
180+
func (c *cluster) Invoke(
181181
ctx context.Context,
182182
method string,
183183
args interface{},
184184
reply interface{},
185185
opts ...grpc.CallOption,
186186
) (err error) {
187-
if db.onInvoke == nil {
187+
if c.onInvoke == nil {
188188
return fmt.Errorf("database.onInvoke() not implemented")
189189
}
190-
return db.onInvoke(ctx, method, args, reply, opts...)
190+
return c.onInvoke(ctx, method, args, reply, opts...)
191191
}
192192

193-
func (db *database) NewStream(
193+
func (c *cluster) NewStream(
194194
ctx context.Context,
195195
desc *grpc.StreamDesc,
196196
method string,
197197
opts ...grpc.CallOption,
198198
) (_ grpc.ClientStream, err error) {
199-
if db.onNewStream == nil {
199+
if c.onNewStream == nil {
200200
return nil, fmt.Errorf("database.onNewStream() not implemented")
201201
}
202-
return db.onNewStream(ctx, desc, method, opts...)
202+
return c.onNewStream(ctx, desc, method, opts...)
203203
}
204204

205-
func (db *database) Get(context.Context) (conn grpc.ClientConnInterface, err error) {
205+
func (c *cluster) Get(context.Context) (conn grpc.ClientConnInterface, err error) {
206206
cc := &clientConn{
207-
onInvoke: db.onInvoke,
208-
onNewStream: db.onNewStream,
207+
onInvoke: c.onInvoke,
208+
onNewStream: c.onNewStream,
209209
}
210210
return cc, nil
211211
}
212212

213-
func (db *database) Name() string {
213+
func (c *cluster) Name() string {
214214
return "testutil.database"
215215
}
216216

217-
func (db *database) Close(ctx context.Context) error {
218-
if db.onClose == nil {
217+
func (c *cluster) Close(ctx context.Context) error {
218+
if c.onClose == nil {
219219
return fmt.Errorf("database.Close() not implemented")
220220
}
221-
return db.onClose(ctx)
221+
return c.onClose(ctx)
222222
}
223223

224224
type (
225225
InvokeHandlers map[MethodCode]func(request interface{}) (result proto.Message, err error)
226226
NewStreamHandlers map[MethodCode]func(desc *grpc.StreamDesc) (grpc.ClientStream, error)
227227
)
228228

229-
type dbOption func(c *database)
229+
type clusterOption func(c *cluster)
230230

231-
func WithInvokeHandlers(invokeHandlers InvokeHandlers) dbOption {
232-
return func(db *database) {
231+
func WithInvokeHandlers(invokeHandlers InvokeHandlers) clusterOption {
232+
return func(db *cluster) {
233233
db.onInvoke = func(
234234
ctx context.Context,
235235
method string,
@@ -260,8 +260,8 @@ func WithInvokeHandlers(invokeHandlers InvokeHandlers) dbOption {
260260
}
261261
}
262262

263-
func WithNewStreamHandlers(newStreamHandlers NewStreamHandlers) dbOption {
264-
return func(db *database) {
263+
func WithNewStreamHandlers(newStreamHandlers NewStreamHandlers) clusterOption {
264+
return func(db *cluster) {
265265
db.onNewStream = func(
266266
ctx context.Context,
267267
desc *grpc.StreamDesc,
@@ -276,14 +276,14 @@ func WithNewStreamHandlers(newStreamHandlers NewStreamHandlers) dbOption {
276276
}
277277
}
278278

279-
func WithClose(onClose func(ctx context.Context) error) dbOption {
280-
return func(c *database) {
279+
func WithClose(onClose func(ctx context.Context) error) clusterOption {
280+
return func(c *cluster) {
281281
c.onClose = onClose
282282
}
283283
}
284284

285-
func NewDB(opts ...dbOption) db.Cluster {
286-
c := &database{}
285+
func NewDB(opts ...clusterOption) database.Cluster {
286+
c := &cluster{}
287287
for _, opt := range opts {
288288
opt(c)
289289
}

0 commit comments

Comments
 (0)