From 5506ba8f64a8648c110f7c70c4564a702e8a5762 Mon Sep 17 00:00:00 2001 From: Nurzhan Saktaganov Date: Mon, 13 Jan 2025 15:38:36 +0300 Subject: [PATCH] api: remove RouterMapCallRWImpl method (resolve #26) --- CHANGELOG.md | 2 +- api.go | 15 --------------- tarantool_test.go | 26 +++++++++++--------------- tests/tnt/concurrent_topology_test.go | 2 +- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c3485..25de18b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ CHANGES: * Removed toolchain go1.23.3. * Refactored GetTyped interface and logic. Now we use raw msg buffer instead raw messages. Interface works and looks like go-tarantool response. -* ReplicaCall, RouterCallImpl methods was removed cause it works invalid and looks useless. +* ReplicaCall, RouterCallImpl, RouterMapCallRWImpl methods was removed cause it works invalid and looks useless. * All PR, issue references in #XYZ format in commits older than 42f363775dfb9eaf7ec2a6ed7a999847752cec00 refer to https://github.com/KaymeKaydex/go-vshard-router. * VshardRouterCallMode type renamed to CallMode for simplicity. * StorageResultTypedFunc type removed as useless type. diff --git a/api.go b/api.go index 7c72f11..8fc2ab8 100644 --- a/api.go +++ b/api.go @@ -539,21 +539,6 @@ func (r *storageRefResponseProto) DecodeMsgpack(d *msgpack.Decoder) error { return nil } -// RouterMapCallRWImpl perform call function on all masters in the cluster -// with a guarantee that in case of success it was executed with all -// buckets being accessible for reads and writes. -// Deprecated: RouterMapCallRWImpl is deprecated. -// Use more general RouterMapCallRW instead. -func (r *Router) RouterMapCallRWImpl( - ctx context.Context, - fnc string, - args interface{}, - opts CallOpts, -) (map[string]interface{}, error) { - // nolint:gosimple - return RouterMapCallRW[interface{}](r, ctx, fnc, args, RouterMapCallRWOptions{Timeout: opts.Timeout}) -} - type replicasetFuture struct { // replicaset name name string diff --git a/tarantool_test.go b/tarantool_test.go index 62559d5..010dd42 100644 --- a/tarantool_test.go +++ b/tarantool_test.go @@ -468,7 +468,7 @@ func BenchmarkCallSimpleSelect_GO_Call(b *testing.B) { b.ReportAllocs() } -func TestRouter_RouterMapCallRWImpl(t *testing.T) { +func TestRouter_RouterMapCallRW(t *testing.T) { t.Parallel() ctx := context.Background() @@ -482,19 +482,16 @@ func TestRouter_RouterMapCallRWImpl(t *testing.T) { }) require.Nil(t, err, "NewRouter created successfully") - err = router.ClusterBootstrap(ctx, false) - require.NoError(t, err) - - callOpts := vshardrouter.CallOpts{} + callOpts := vshardrouter.RouterMapCallRWOptions{} const arg = "arg1" // Enusre that RouterMapCallRWImpl works at all echoArgs := []interface{}{arg} - resp, err := router.RouterMapCallRWImpl(ctx, "echo", echoArgs, callOpts) + respStr, err := vshardrouter.RouterMapCallRW[string](router, ctx, "echo", echoArgs, callOpts) require.NoError(t, err, "RouterMapCallRWImpl echo finished with no err") - for k, v := range resp { + for k, v := range respStr { require.Equalf(t, arg, v, "RouterMapCallRWImpl value ok for %v", k) } @@ -507,16 +504,16 @@ func TestRouter_RouterMapCallRWImpl(t *testing.T) { // RouterMapCallRWImpl returns only one value echoArgs = []interface{}{arg, "arg2"} - resp, err = router.RouterMapCallRWImpl(ctx, "echo", echoArgs, callOpts) + respStr, err = vshardrouter.RouterMapCallRW[string](router, ctx, "echo", echoArgs, callOpts) require.NoError(t, err, "RouterMapCallRWImpl echo finished with no err") - for k, v := range resp { + for k, v := range respStr { require.Equalf(t, arg, v, "RouterMapCallRWImpl value ok for %v", k) } // RouterMapCallRWImpl returns nil when no return value noArgs := []interface{}{} - resp, err = router.RouterMapCallRWImpl(ctx, "echo", noArgs, callOpts) + resp, err := vshardrouter.RouterMapCallRW[interface{}](router, ctx, "echo", noArgs, callOpts) require.NoError(t, err, "RouterMapCallRWImpl echo finished with no err") for k, v := range resp { @@ -528,7 +525,7 @@ func TestRouter_RouterMapCallRWImpl(t *testing.T) { sleepArgs := []interface{}{sleepToSec} start := time.Now() - _, err = router.RouterMapCallRWImpl(ctx, "sleep", sleepArgs, vshardrouter.CallOpts{ + _, err = vshardrouter.RouterMapCallRW[interface{}](router, ctx, "sleep", sleepArgs, vshardrouter.RouterMapCallRWOptions{ Timeout: 2 * time.Second, // because default timeout is 0.5 sec }) duration := time.Since(start) @@ -538,21 +535,20 @@ func TestRouter_RouterMapCallRWImpl(t *testing.T) { require.Less(t, duration, 1200*time.Millisecond, "Requests were send concurrently") // RouterMapCallRWImpl returns err on raise_luajit_error - _, err = router.RouterMapCallRWImpl(ctx, "raise_luajit_error", noArgs, callOpts) + _, err = vshardrouter.RouterMapCallRW[interface{}](router, ctx, "raise_luajit_error", noArgs, callOpts) require.NotNil(t, err, "RouterMapCallRWImpl raise_luajit_error finished with error") // RouterMapCallRWImpl invalid usage - _, err = router.RouterMapCallRWImpl(ctx, "echo", nil, callOpts) + _, err = vshardrouter.RouterMapCallRW[interface{}](router, ctx, "echo", nil, callOpts) require.NotNil(t, err, "RouterMapCallRWImpl with nil args finished with error") // Ensure that RouterMapCallRWImpl doesn't work when it mean't to for rsInfo := range topology { errs := router.RemoveReplicaset(ctx, rsInfo.Name) require.Emptyf(t, errs, "%s successfully removed from router", rsInfo.Name) - break } - _, err = router.RouterMapCallRWImpl(ctx, "echo", echoArgs, callOpts) + _, err = vshardrouter.RouterMapCallRW[interface{}](router, ctx, "echo", echoArgs, callOpts) require.NotNilf(t, err, "RouterMapCallRWImpl failed on not full cluster") } diff --git a/tests/tnt/concurrent_topology_test.go b/tests/tnt/concurrent_topology_test.go index 582a6ce..6ecd4ad 100644 --- a/tests/tnt/concurrent_topology_test.go +++ b/tests/tnt/concurrent_topology_test.go @@ -168,7 +168,7 @@ func TestConncurrentTopologyChange(t *testing.T) { } args := []interface{}{"arg1"} - _, _ = router.RouterMapCallRWImpl(ctx, "echo", args, vshardrouter.CallOpts{}) + _, _ = vshardrouter.RouterMapCallRW[interface{}](router, ctx, "echo", args, vshardrouter.RouterMapCallRWOptions{}) } }()