Skip to content

Commit

Permalink
api: remove RouterMapCallRWImpl method (resolve #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
nurzhan-saktaganov committed Jan 13, 2025
1 parent a284589 commit 5506ba8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 0 additions & 15 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 11 additions & 15 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}

Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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")
}
2 changes: 1 addition & 1 deletion tests/tnt/concurrent_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}
}()

Expand Down

0 comments on commit 5506ba8

Please sign in to comment.