From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 1EA726E454; Wed, 9 Feb 2022 03:34:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1EA726E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1644366850; bh=0FOenV7fdrDWDwSG6Eh2w+Kbn4qwssAVRWQsTyw278U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=N9u7QfaKJbatanjmGR5h9NSNZWQhscu5w54bSf6tgJMCcKG6VoryhlDbYN7rL8fUx on5oOWU6trs5Fnyfc4FTEHpW11qPOFq1IJ1kE1xo8qanf8qg1aup4YgsuZNBlO4Ekf ak9iFIKx3YriiRYn7ar6fq/bGFUS1y+k9Y8RHdv0= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 51FDC6E229 for ; Wed, 9 Feb 2022 03:32:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 51FDC6E229 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1nHauT-00019d-Ki; Wed, 09 Feb 2022 03:32:38 +0300 To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org Date: Wed, 9 Feb 2022 01:32:33 +0100 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9B74B50284A7C1A0BDB3817FC5E3D06AF66A67DDACF5723F5182A05F538085040F92EFFCF7CAA96FC5200E05D66CFDADC9E8B80FE9FFABCC63D749564961E1EBF X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FC0948D7756001208638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D81637EB989D87933C63AA28E8B8C32D64117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C289736CE4F78F08343847C11F186F3C59DAA53EE0834AAEE X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CB976C8CDE8F8DDC865E3F5599A92471CDE4FFFB0182ED00F9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF4AAE2D1698E8717B699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348F9E8EBB462314871BE5E3998389DB392A64598622A374C951CD7D166945BE3AE646DEAC4A4322571D7E09C32AA3244C70312700372CAB08DE003F5448035D6039C99C45E8D137E9729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojkCH2JBCxyk0SRS7yTneGCQ== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D63C1C7597A6EF532F9EFFFDF1C3BD10263841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E25FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH vshard 3/4] router: support msgpack object args X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Msgpack object allows to represent scalar values and tables with them as a raw MessagePack buffer. It will be introduced after 2.10.0-beta2. It can be used in most of the places which used to take arguments for further encoding into MessagePack anyway. Including netbox API. Usage of msgpack object allows not to decode the buffer if it was received from a remote instance for further proxying. It is simply memcpy-ed into a next call. VShard.router almost supported this feature. Only needed to change the arguments type check. But even better - simply drop it and trust netbox to do the type check. Part of #312 --- test/instances/router.lua | 1 + test/router-luatest/router_test.lua | 47 +++++++++++++++++++++++++++++ vshard/replicaset.lua | 4 --- vshard/util.lua | 9 ++++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/test/instances/router.lua b/test/instances/router.lua index ccec6c1..921ac73 100755 --- a/test/instances/router.lua +++ b/test/instances/router.lua @@ -1,5 +1,6 @@ #!/usr/bin/env tarantool local helpers = require('test.luatest_helpers') +_G.msgpack = require('msgpack') -- Do not load entire vshard into the global namespace to catch errors when code -- relies on that. _G.vshard = { diff --git a/test/router-luatest/router_test.lua b/test/router-luatest/router_test.lua index 621794a..13ab74d 100644 --- a/test/router-luatest/router_test.lua +++ b/test/router-luatest/router_test.lua @@ -1,5 +1,6 @@ local t = require('luatest') local vtest = require('test.luatest_helpers.vtest') +local vutil = require('vshard.util') local wait_timeout = 120 local g = t.group('router') @@ -52,3 +53,49 @@ g.test_basic = function(g) t.assert(not err, 'no error') t.assert_equals(res, 1, 'good result') end + +if vutil.feature.msgpack_object then + +g.test_msgpack_args = function(g) + local router = g.router + -- + -- Normal call ro. + -- + local res, err = router:exec(function(timeout) + local args = msgpack.object({100}) + return vshard.router.callrw(1, 'echo', args, {timeout = timeout}) + end, {wait_timeout}) + t.assert(not err, 'no error') + t.assert_equals(res, 100, 'good result') + -- + -- Normal call rw. + -- + res, err = router:exec(function(timeout) + local args = msgpack.object({100}) + return vshard.router.callro(1, 'echo', args, {timeout = timeout}) + end, {wait_timeout}) + t.assert(not err, 'no error') + t.assert_equals(res, 100, 'good result') + -- + -- Direct call ro. + -- + res, err = router:exec(function(timeout) + local args = msgpack.object({100}) + local route = vshard.router.route(1) + return route:callro('echo', args, {timeout = timeout}) + end, {wait_timeout}) + t.assert(err == nil, 'no error') + t.assert_equals(res, 100, 'good result') + -- + -- Direct call rw. + -- + res, err = router:exec(function(timeout) + local args = msgpack.object({100}) + local route = vshard.router.route(1) + return route:callrw('echo', args, {timeout = timeout}) + end, {wait_timeout}) + t.assert(err == nil, 'no error') + t.assert_equals(res, 100, 'good result') +end + +end -- vutil.feature.msgpack_object diff --git a/vshard/replicaset.lua b/vshard/replicaset.lua index 8e5526a..16b89aa 100644 --- a/vshard/replicaset.lua +++ b/vshard/replicaset.lua @@ -408,8 +408,6 @@ end -- local function replicaset_master_call(replicaset, func, args, opts) assert(opts == nil or type(opts) == 'table') - assert(type(func) == 'string', 'function name') - assert(args == nil or type(args) == 'table', 'function arguments') local master = replicaset.master if not master then opts = opts and table.copy(opts) or {} @@ -552,8 +550,6 @@ local function replicaset_template_multicallro(prefer_replica, balance) return function(replicaset, func, args, opts) assert(opts == nil or type(opts) == 'table') - assert(type(func) == 'string', 'function name') - assert(args == nil or type(args) == 'table', 'function arguments') opts = opts and table.copy(opts) or {} local timeout = opts.timeout or consts.CALL_TIMEOUT_MAX local net_status, storage_status, retval, err, replica diff --git a/vshard/util.lua b/vshard/util.lua index 9e0212a..72176f7 100644 --- a/vshard/util.lua +++ b/vshard/util.lua @@ -230,6 +230,14 @@ local function fiber_is_self_canceled() return not pcall(fiber.testcancel) end +-- +-- Dictionary of supported core features on the given instance. Try to use it +-- in all the other code rather than direct version check. +-- +local feature = { + msgpack_object = version_is_at_least(2, 10, 0, 'beta', 2, 86), +} + return { tuple_extract_key = tuple_extract_key, reloadable_fiber_create = reloadable_fiber_create, @@ -241,4 +249,5 @@ return { table_minus_yield = table_minus_yield, fiber_cond_wait = fiber_cond_wait, fiber_is_self_canceled = fiber_is_self_canceled, + feature = feature, } -- 2.24.3 (Apple Git-128)