Skip to content

Commit 0fbe2f9

Browse files
Add failover.set_options (#2129)
1 parent f3002f2 commit 0fbe2f9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Fixed
1818

1919
- Fix operation priority in Raft failover.
2020

21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
Added
23+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
- New Failover API function ``set_options`` to change failover internal params.
26+
2127
-------------------------------------------------------------------------------
2228
[2.8.1] - 2023-07-20
2329
-------------------------------------------------------------------------------

cartridge/failover.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ local SwitchoverError = errors.new_class('SwitchoverError')
5050
local ApplyConfigError = errors.new_class('ApplyConfigError')
5151
local ValidateConfigError = errors.new_class('ValidateConfigError')
5252
local StateProviderError = errors.new_class('StateProviderError')
53+
local SetOptionsError = errors.new_class('SetOptionsError')
5354

5455
vars:new('mode')
5556
vars:new('all_roles')
@@ -1142,12 +1143,38 @@ local function wait_consistency(leaders)
11421143
return true
11431144
end
11441145

1146+
--- Set internal failover options.
1147+
--
1148+
-- Available options are: WAITLSN_PAUSE, WAITLSN_TIMEOUT, LONGPOLL_TIMEOUT, NETBOX_CALL_TIMEOUT
1149+
--
1150+
-- @function set_options
1151+
-- @local
1152+
-- @treturn[1] boolean true
1153+
-- @treturn[2] nil
1154+
-- @treturn[2] table Error description
1155+
local function set_options(opts)
1156+
checks('table')
1157+
for k, v in pairs(opts) do
1158+
if vars.options[k] == nil then
1159+
return nil, SetOptionsError:new(('Invalid option %s'):format(k))
1160+
end
1161+
if type(v) ~= "number" then
1162+
return nil, SetOptionsError:new(('Invalid option %s value, expected number'):format(k))
1163+
end
1164+
end
1165+
for k, v in pairs(opts) do
1166+
vars.options[k] = v
1167+
end
1168+
return true
1169+
end
1170+
11451171
return {
11461172
cfg = cfg,
11471173
get_active_leaders = get_active_leaders,
11481174
get_coordinator = get_coordinator,
11491175
get_error = get_error,
11501176
check_cookie_hash_error = check_cookie_hash_error,
1177+
set_options = set_options,
11511178

11521179
consistency_needed = consistency_needed,
11531180
is_vclockkeeper = is_vclockkeeper,

0 commit comments

Comments
 (0)