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 7F1136E454; Wed, 9 Feb 2022 20:54:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7F1136E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1644429271; bh=kXVG+AxA1jAa4VxC5hqTxAkUJMCwTtAUcAz4MKUvD4w=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VR9ALB6/r9aYbtsccpSPO69URA6U6mlxbGtfxuex2rlNdlAbjupkTDEhFKE3ROnQJ SXEY7oH/tOUHKYuPzkdvzt1f2JO5fFCzWGkFTspQdsvDYchQD8nwz2Kbk2i8mO2sRJ UU4kTjeYFN3nOtzjQsItrWKXs/IdXNJt44VxpLIg= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (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 759B06E454 for ; Wed, 9 Feb 2022 20:53:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 759B06E454 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1nHr9y-0002sC-RV; Wed, 09 Feb 2022 20:53:43 +0300 Message-ID: <91cc3506-003f-cfbe-c02f-f49f9505cf87@tarantool.org> Date: Wed, 9 Feb 2022 20:53:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9B74B50284A7C1A0BC757C3396C1D21A450824C43D37379F8182A05F5380850409149302B550522C8398D86D55EC5A812A5B2399C1F86612936D7F9C13CBB9ED3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE728F774C865CF4B07EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375E280A1EC162AD7D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8051E2FCA10221F3FECF6C343C1DD4E1F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B8F49F126DDB898E8D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A7DFDF579AB090EF2D242C3BD2E3F4C6C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A511ECDE3559344A635CDC9E2765BD2D01AD23E435BE3609D6D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BFC02AB3DF06BA5A410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346BEB6F73FB9D1E4A5C17BF867B4E3501F3BF722A900A0AC4AAF5DC42A25F5102F5976A2059191BCC1D7E09C32AA3244CD5E78A3B4ED43D75A6DD7C437B688686F2F5F14F68F1805B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojptAT+HCMDqMaAptczUJc5A== X-Mailru-Sender: 583F1D7ACE8F49BD508BD8DBBD09B14DF6327956ED8DA88DC270E3CB9EC384DAAE66FB262F053E3080EE221D05932256AD9BA6614E257C8ED9E51C16F2486AFBE342CF4F05FB7E8CB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [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: Oleg Babin via Tarantool-patches Reply-To: Oleg Babin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for your patch. Two comments below. On 09.02.2022 03:32, Vladislav Shpilevoy wrote: > 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 You could use g.skip_if(vutil.feature.msgpack_object) instead of conditional test declaration. > + > +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), > +} It could be simplified to `require('msgpack').object ~= nil` > + > 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, > }