@@ -50,6 +50,7 @@ local SwitchoverError = errors.new_class('SwitchoverError')
50
50
local ApplyConfigError = errors .new_class (' ApplyConfigError' )
51
51
local ValidateConfigError = errors .new_class (' ValidateConfigError' )
52
52
local StateProviderError = errors .new_class (' StateProviderError' )
53
+ local SetOptionsError = errors .new_class (' SetOptionsError' )
53
54
54
55
vars :new (' mode' )
55
56
vars :new (' all_roles' )
@@ -1142,12 +1143,38 @@ local function wait_consistency(leaders)
1142
1143
return true
1143
1144
end
1144
1145
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
+
1145
1171
return {
1146
1172
cfg = cfg ,
1147
1173
get_active_leaders = get_active_leaders ,
1148
1174
get_coordinator = get_coordinator ,
1149
1175
get_error = get_error ,
1150
1176
check_cookie_hash_error = check_cookie_hash_error ,
1177
+ set_options = set_options ,
1151
1178
1152
1179
consistency_needed = consistency_needed ,
1153
1180
is_vclockkeeper = is_vclockkeeper ,
0 commit comments