Skip to content

Commit

Permalink
Add Pooler method to replicaset that returns Pooler interface
Browse files Browse the repository at this point in the history
  • Loading branch information
maksim.konovalov authored and KaymeKaydex committed Jan 13, 2025
1 parent 3e9359e commit df5c4b3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased

FEATURES:

* Implemented Pooler method that returns go-tarantool Pooler interface. That can be used by some go-tarantool modules(
like box).

BUG FIXES:

* ClusterBootstrap: eliminate direct access to r.idToReplicaset.
Expand Down
4 changes: 4 additions & 0 deletions replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ type Replicaset struct {
EtalonBucketCount uint64
}

func (rs *Replicaset) Pooler() pool.Pooler {
return rs.conn
}

func (rs *Replicaset) String() string {
return rs.info.String()
}
Expand Down
28 changes: 28 additions & 0 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/tarantool/go-tarantool/v2"
"github.com/tarantool/go-tarantool/v2/box"
"github.com/tarantool/go-tarantool/v2/pool"
"github.com/tarantool/go-tarantool/v2/test_helpers"
vshardrouter "github.com/tarantool/go-vshard-router"
"github.com/tarantool/go-vshard-router/providers/static"
Expand Down Expand Up @@ -611,3 +613,29 @@ func testRouterRouteWithMode(t *testing.T, searchMode vshardrouter.BucketsSearch
}
}
}

// TestReplicaset_Pooler tests that pooler logic works ok with replicaset.
func TestReplicaset_Pooler(t *testing.T) {
ctx := context.Background()

router, err := vshardrouter.NewRouter(ctx, vshardrouter.Config{
TopologyProvider: static.NewProvider(topology),
DiscoveryTimeout: 5 * time.Second,
DiscoveryMode: vshardrouter.DiscoveryModeOn,
TotalBucketCount: totalBucketCount,
User: username,
})
require.Nil(t, err, "NewRouter created successfully")

t.Run("go-tarantool box module works ok with go-vshard replicaset", func(t *testing.T) {
// check that masters are alive
for _, rs := range router.RouteAll() {
b := box.New(pool.NewConnectorAdapter(rs.Pooler(), pool.RW))
require.NotNil(t, b)

info, err := b.Info()
require.NoError(t, err, "master respond info")
require.False(t, info.RO, "it is not RO")
}
})
}

0 comments on commit df5c4b3

Please sign in to comment.