Skip to content

Commit c66accd

Browse files
committed
api: rename connection_pool to pool
By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps [1]. 1. https://go.dev/doc/effective_go#package-names Closes #239
1 parent acfefc7 commit c66accd

21 files changed

+352
-342
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1212

1313
### Changed
1414

15+
- connection_pool renamed to pool (#239)
16+
1517
### Removed
1618

1719
- multi subpackage (#240)

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ testrace:
5757
go clean -testcache
5858
go test -race -tags "$(TAGS)" ./... -v -p 1
5959

60-
.PHONY: test-connection-pool
61-
test-connection-pool:
62-
@echo "Running tests in connection_pool package"
60+
.PHONY: test-pool
61+
test-pool:
62+
@echo "Running tests in pool package"
6363
go clean -testcache
64-
go test -tags "$(TAGS)" ./connection_pool/ -v -p 1
64+
go test -tags "$(TAGS)" ./pool/ -v -p 1
6565

6666
.PHONY: test-datetime
6767
test-datetime:

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ faster than other packages according to public benchmarks.
2828
* [Walking\-through example](#walking-through-example)
2929
* [Migration to v2](#migration-to-v2)
3030
* [multi package](#multi-package)
31+
* [pool package](#pool-package)
3132
* [msgpack.v5](#msgpackv5)
3233
* [Contributing](#contributing)
3334
* [Alternative connectors](#alternative-connectors)
@@ -161,7 +162,14 @@ The article describes migration from go-tarantool to go-tarantool/v2.
161162

162163
#### multi package
163164

164-
The subpackage has been deleted. You could use `connection_pool` instead.
165+
The subpackage has been deleted. You could use `pool` instead.
166+
167+
#### pool package
168+
169+
The logic has not changed, but there are a few renames:
170+
171+
* The `connection_pool` subpackage has been renamed to `pool`.
172+
* The type `PoolOpts` has been renamed to `Opts`.
165173

166174
#### msgpack.v5
167175

connection_pool/call_16_test.go renamed to pool/call_16_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//go:build !go_tarantool_call_17
22
// +build !go_tarantool_call_17
33

4-
package connection_pool_test
4+
package pool_test
55

66
import (
77
"testing"
88

99
"github.com/stretchr/testify/require"
10-
"github.com/tarantool/go-tarantool/v2/connection_pool"
10+
"github.com/tarantool/go-tarantool/v2/pool"
1111
"github.com/tarantool/go-tarantool/v2/test_helpers"
1212
)
1313

@@ -17,14 +17,14 @@ func TestCall(t *testing.T) {
1717
err := test_helpers.SetClusterRO(servers, connOpts, roles)
1818
require.Nilf(t, err, "fail to set roles for cluster")
1919

20-
connPool, err := connection_pool.Connect(servers, connOpts)
20+
connPool, err := pool.Connect(servers, connOpts)
2121
require.Nilf(t, err, "failed to connect")
2222
require.NotNilf(t, connPool, "conn is nil after Connect")
2323

2424
defer connPool.Close()
2525

2626
// PreferRO
27-
resp, err := connPool.Call("box.info", []interface{}{}, connection_pool.PreferRO)
27+
resp, err := connPool.Call("box.info", []interface{}{}, pool.PreferRO)
2828
require.Nilf(t, err, "failed to Call")
2929
require.NotNilf(t, resp, "response is nil after Call")
3030
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -35,7 +35,7 @@ func TestCall(t *testing.T) {
3535
require.Truef(t, ro, "expected `true` with mode `PreferRO`")
3636

3737
// PreferRW
38-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.PreferRW)
38+
resp, err = connPool.Call("box.info", []interface{}{}, pool.PreferRW)
3939
require.Nilf(t, err, "failed to Call")
4040
require.NotNilf(t, resp, "response is nil after Call")
4141
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -46,7 +46,7 @@ func TestCall(t *testing.T) {
4646
require.Falsef(t, ro, "expected `false` with mode `PreferRW`")
4747

4848
// RO
49-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.RO)
49+
resp, err = connPool.Call("box.info", []interface{}{}, pool.RO)
5050
require.Nilf(t, err, "failed to Call")
5151
require.NotNilf(t, resp, "response is nil after Call")
5252
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -57,7 +57,7 @@ func TestCall(t *testing.T) {
5757
require.Truef(t, ro, "expected `true` with mode `RO`")
5858

5959
// RW
60-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.RW)
60+
resp, err = connPool.Call("box.info", []interface{}{}, pool.RW)
6161
require.Nilf(t, err, "failed to Call")
6262
require.NotNilf(t, resp, "response is nil after Call")
6363
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")

connection_pool/call_17_test.go renamed to pool/call_17_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//go:build go_tarantool_call_17
22
// +build go_tarantool_call_17
33

4-
package connection_pool_test
4+
package pool_test
55

66
import (
77
"testing"
88

99
"github.com/stretchr/testify/require"
10-
"github.com/tarantool/go-tarantool/v2/connection_pool"
10+
"github.com/tarantool/go-tarantool/v2/pool"
1111
"github.com/tarantool/go-tarantool/v2/test_helpers"
1212
)
1313

@@ -17,14 +17,14 @@ func TestCall(t *testing.T) {
1717
err := test_helpers.SetClusterRO(servers, connOpts, roles)
1818
require.Nilf(t, err, "fail to set roles for cluster")
1919

20-
connPool, err := connection_pool.Connect(servers, connOpts)
20+
connPool, err := pool.Connect(servers, connOpts)
2121
require.Nilf(t, err, "failed to connect")
2222
require.NotNilf(t, connPool, "conn is nil after Connect")
2323

2424
defer connPool.Close()
2525

2626
// PreferRO
27-
resp, err := connPool.Call("box.info", []interface{}{}, connection_pool.PreferRO)
27+
resp, err := connPool.Call("box.info", []interface{}{}, pool.PreferRO)
2828
require.Nilf(t, err, "failed to Call")
2929
require.NotNilf(t, resp, "response is nil after Call")
3030
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -35,7 +35,7 @@ func TestCall(t *testing.T) {
3535
require.Truef(t, ro, "expected `true` with mode `PreferRO`")
3636

3737
// PreferRW
38-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.PreferRW)
38+
resp, err = connPool.Call("box.info", []interface{}{}, pool.PreferRW)
3939
require.Nilf(t, err, "failed to Call")
4040
require.NotNilf(t, resp, "response is nil after Call")
4141
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -46,7 +46,7 @@ func TestCall(t *testing.T) {
4646
require.Falsef(t, ro, "expected `false` with mode `PreferRW`")
4747

4848
// RO
49-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.RO)
49+
resp, err = connPool.Call("box.info", []interface{}{}, pool.RO)
5050
require.Nilf(t, err, "failed to Call")
5151
require.NotNilf(t, resp, "response is nil after Call")
5252
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
@@ -57,7 +57,7 @@ func TestCall(t *testing.T) {
5757
require.Truef(t, ro, "expected `true` with mode `RO`")
5858

5959
// RW
60-
resp, err = connPool.Call("box.info", []interface{}{}, connection_pool.RW)
60+
resp, err = connPool.Call("box.info", []interface{}{}, pool.RW)
6161
require.Nilf(t, err, "failed to Call")
6262
require.NotNilf(t, resp, "response is nil after Call")
6363
require.GreaterOrEqualf(t, len(resp.Data), 1, "response.Data is empty after Call")
File renamed without changes.

connection_pool/connection_pool.go renamed to pool/connection_pool.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// - Automatic master discovery by mode parameter.
99
//
1010
// Since: 1.6.0
11-
package connection_pool
11+
package pool
1212

1313
import (
1414
"errors"
@@ -59,8 +59,8 @@ type ConnectionHandler interface {
5959
Deactivated(conn *tarantool.Connection, role Role) error
6060
}
6161

62-
// OptsPool provides additional options (configurable via ConnectWithOpts).
63-
type OptsPool struct {
62+
// Opts provides additional options (configurable via ConnectWithOpts).
63+
type Opts struct {
6464
// Timeout for timer to reopen connections that have been closed by some
6565
// events and to relocate connection between subpools if ro/rw role has
6666
// been updated.
@@ -93,7 +93,7 @@ type ConnectionPool struct {
9393
addrsMutex sync.RWMutex
9494

9595
connOpts tarantool.Opts
96-
opts OptsPool
96+
opts Opts
9797

9898
state state
9999
done chan struct{}
@@ -132,7 +132,7 @@ func newEndpoint(addr string) *endpoint {
132132

133133
// ConnectWithOpts creates pool for instances with addresses addrs
134134
// with options opts.
135-
func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsPool) (connPool *ConnectionPool, err error) {
135+
func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts Opts) (connPool *ConnectionPool, err error) {
136136
if len(addrs) == 0 {
137137
return nil, ErrEmptyAddrs
138138
}
@@ -179,9 +179,9 @@ func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsPool) (co
179179
//
180180
// It is useless to set up tarantool.Opts.Reconnect value for a connection.
181181
// The connection pool has its own reconnection logic. See
182-
// OptsPool.CheckTimeout description.
182+
// Opts.CheckTimeout description.
183183
func Connect(addrs []string, connOpts tarantool.Opts) (connPool *ConnectionPool, err error) {
184-
opts := OptsPool{
184+
opts := Opts{
185185
CheckTimeout: 1 * time.Second,
186186
}
187187
return ConnectWithOpts(addrs, connOpts, opts)

0 commit comments

Comments
 (0)