Skip to content

Commit df5c4b3

Browse files
maksim.konovalovKaymeKaydex
authored andcommitted
Add Pooler method to replicaset that returns Pooler interface
1 parent 3e9359e commit df5c4b3

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Unreleased
22

3+
FEATURES:
4+
5+
* Implemented Pooler method that returns go-tarantool Pooler interface. That can be used by some go-tarantool modules(
6+
like box).
7+
38
BUG FIXES:
49

510
* ClusterBootstrap: eliminate direct access to r.idToReplicaset.

replicaset.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ type Replicaset struct {
5555
EtalonBucketCount uint64
5656
}
5757

58+
func (rs *Replicaset) Pooler() pool.Pooler {
59+
return rs.conn
60+
}
61+
5862
func (rs *Replicaset) String() string {
5963
return rs.info.String()
6064
}

tarantool_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/google/uuid"
1313
"github.com/stretchr/testify/require"
1414
"github.com/tarantool/go-tarantool/v2"
15+
"github.com/tarantool/go-tarantool/v2/box"
16+
"github.com/tarantool/go-tarantool/v2/pool"
1517
"github.com/tarantool/go-tarantool/v2/test_helpers"
1618
vshardrouter "github.com/tarantool/go-vshard-router"
1719
"github.com/tarantool/go-vshard-router/providers/static"
@@ -611,3 +613,29 @@ func testRouterRouteWithMode(t *testing.T, searchMode vshardrouter.BucketsSearch
611613
}
612614
}
613615
}
616+
617+
// TestReplicaset_Pooler tests that pooler logic works ok with replicaset.
618+
func TestReplicaset_Pooler(t *testing.T) {
619+
ctx := context.Background()
620+
621+
router, err := vshardrouter.NewRouter(ctx, vshardrouter.Config{
622+
TopologyProvider: static.NewProvider(topology),
623+
DiscoveryTimeout: 5 * time.Second,
624+
DiscoveryMode: vshardrouter.DiscoveryModeOn,
625+
TotalBucketCount: totalBucketCount,
626+
User: username,
627+
})
628+
require.Nil(t, err, "NewRouter created successfully")
629+
630+
t.Run("go-tarantool box module works ok with go-vshard replicaset", func(t *testing.T) {
631+
// check that masters are alive
632+
for _, rs := range router.RouteAll() {
633+
b := box.New(pool.NewConnectorAdapter(rs.Pooler(), pool.RW))
634+
require.NotNil(t, b)
635+
636+
info, err := b.Info()
637+
require.NoError(t, err, "master respond info")
638+
require.False(t, info.RO, "it is not RO")
639+
}
640+
})
641+
}

0 commit comments

Comments
 (0)