sentinel_password = ts.string:is_optional(),
}
-local config_schema = -- Allow separate read/write servers to allow usage in the `extra_fields`
-ts.shape({
+local read_schema = lutil.table_merge({
read_servers = ts.string + ts.array_of(ts.string),
-}, { extra_fields = common_schema }) +
- ts.shape({
- write_servers = ts.string + ts.array_of(ts.string),
- }, { extra_fields = common_schema }) +
- ts.shape({
- read_servers = ts.string + ts.array_of(ts.string),
- write_servers = ts.string + ts.array_of(ts.string),
- }, { extra_fields = common_schema }) +
- ts.shape({
- servers = ts.string + ts.array_of(ts.string),
- }, { extra_fields = common_schema }) +
- ts.shape({
- server = ts.string + ts.array_of(ts.string),
- }, { extra_fields = common_schema })
-
-exports.config_schema = config_schema
+}, common_schema)
+
+local write_schema = lutil.table_merge({
+ write_servers = ts.string + ts.array_of(ts.string),
+}, common_schema)
+
+local rw_schema = lutil.table_merge({
+ read_servers = ts.string + ts.array_of(ts.string),
+ write_servers = ts.string + ts.array_of(ts.string),
+}, common_schema)
+
+local servers_schema = lutil.table_merge({
+ servers = ts.string + ts.array_of(ts.string),
+}, common_schema)
+
+local server_schema = lutil.table_merge({
+ server = ts.string + ts.array_of(ts.string),
+}, common_schema)
+
+local generate_schema = function(external)
+ return ts.one_of {
+ ts.shape(external),
+ ts.shape(lutil.table_merge(read_schema, external)),
+ ts.shape(lutil.table_merge(write_schema, external)),
+ ts.shape(lutil.table_merge(rw_schema, external)),
+ ts.shape(lutil.table_merge(servers_schema, external)),
+ ts.shape(lutil.table_merge(server_schema, external)),
+ }
+end
+
+exports.generate_schema = generate_schema
local function redis_query_sentinel(ev_base, params, initialised)
local function flatten_redis_table(tbl)
end
local function prepare_redis_call(script)
- local function merge_tables(t1, t2)
- for k, v in pairs(t2) do
- t1[k] = v
- end
- end
-
local servers = {}
local options = {}
if script.redis_params.read_servers then
- merge_tables(servers, script.redis_params.read_servers:all_upstreams())
+ lutil.table_merge(servers, script.redis_params.read_servers:all_upstreams())
end
if script.redis_params.write_servers then
- merge_tables(servers, script.redis_params.write_servers:all_upstreams())
+ lutil.table_merge(servers, script.redis_params.write_servers:all_upstreams())
end
-- Call load script on each server, set loaded flag
}
local redis_params
-local settings_schema = ts.shape({
+local settings_schema = lua_redis.generate_schema({
helper_url = ts.string,
helper_timeout = ts.number + ts.string / lua_util.parse_time_interval,
helper_sync = ts.boolean,
redis_min_expiry = ts.number + ts.string / lua_util.parse_time_interval,
redis_prefix = ts.string,
enabled = ts.boolean:is_optional(),
-}, {extra_fields = lua_redis.config_schema})
+})
local function check_dmarc_policy(task)
local dmarc_sym = task:get_symbol('DMARC_POLICY_ALLOW')
rspamd_config:register_dependency('BIMI_CHECK', 'DMARC_CHECK')
else
lua_util.disable_module(N, "redis")
-end
\ No newline at end of file
+end
subject_privacy_length = 16, -- cut the length of the hash
}
-local settings_schema = ts.shape({
+local settings_schema = lua_redis.generate_schema({
key_prefix = ts.string,
expire = (ts.number + ts.string / lua_util.parse_time_interval):is_optional(),
nrows = ts.number,
subject_privacy_alg = ts.string:is_optional(),
subject_privacy_prefix = ts.string:is_optional(),
subject_privacy_length = ts.number:is_optional(),
-}, {extra_fields = lua_redis.config_schema})
+})
local function process_addr(addr)
if addr then