Skip to content

Commit

Permalink
Added compatibility with Tarantool 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
wey1and authored and akudiyar committed Jul 25, 2021
1 parent d104d2b commit 41fc76d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/test/resources/cartridge/app/roles/api_router.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local vshard = require('vshard')
local cartridge_pool = require('cartridge.pool')
local cartridge_rpc = require('cartridge.rpc')
local fiber = require('fiber')
local log = require('log')
Expand Down Expand Up @@ -31,7 +30,7 @@ local function retrying_function()
end

local function get_composite_data(id)
local data = vshard.router.callro(vshard.router.bucket_id(id), 'get_composite_data', {id})
local data = vshard.router.callro(vshard.router.bucket_id(id), 'get_composite_data', { id })
return data
end

Expand All @@ -57,7 +56,7 @@ local function raising_error(message)
end

local function reset_request_counters()
box.space.request_counters:replace({1, 0})
box.space.request_counters:replace({ 1, 0 })
end

local function get_router_name()
Expand All @@ -77,15 +76,18 @@ local function long_running_function(values)
end
end

box.space.request_counters:update(1, {{'+', 'count', 1}})
-- need using number instead field name as string in update function for compatibility with tarantool 1.10
box.space.request_counters:update(1, { { '+', 2, 1 } })
log.info('Executing long-running function ' ..
tostring(box.space.request_counters:get(1)[2]) ..
"(name: " .. disabled_router_name ..
"; sleep: " .. seconds_to_sleep .. ")")
if get_router_name() == disabled_router_name then
return nil, "Disabled by client; router_name = " .. disabled_router_name
return nil, "Disabled by client; router_name = " .. disabled_router_name
end
if seconds_to_sleep then
fiber.sleep(seconds_to_sleep)
end
if seconds_to_sleep then fiber.sleep(seconds_to_sleep) end
return true
end

Expand Down Expand Up @@ -117,10 +119,10 @@ end
local function init(opts)

box.schema.space.create('request_counters', {
format = {{'id', 'unsigned'}, {'count', 'unsigned'}},
format = { { 'id', 'unsigned' }, { 'count', 'unsigned' } },
if_not_exists = true
})
box.space.request_counters:create_index('primary', {parts = {'id'}, if_not_exists = true})
box.space.request_counters:create_index('id', { parts = { 'id' }, if_not_exists = true })

rawset(_G, 'truncate_space', truncate_space)

Expand Down

0 comments on commit 41fc76d

Please sign in to comment.