From: AKhatskevich <avkhatskevich@tarantool.org>
To: v.shpilevoy@tarantool.org, tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH] Refactor config templates
Date: Fri, 3 Aug 2018 23:07:44 +0300 [thread overview]
Message-ID: <20180803200744.18515-1-avkhatskevich@tarantool.org> (raw)
In-Reply-To: <cover.1533054045.git.avkhatskevich@tarantool.org>
Config templates are converted to dictionary format.
Before: format = {{field_name, description}}
After: format = {field_name = description]]
This change is made for fast template lookups, which will be used
in further commits.
---
This is an extra commit, created especially for the
'Update only vshard part of a cfg on reload' patch.
vshard/cfg.lua | 64 ++++++++++++++++++++++++++++------------------------------
1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/vshard/cfg.lua b/vshard/cfg.lua
index bba12cc..7c9ab77 100644
--- a/vshard/cfg.lua
+++ b/vshard/cfg.lua
@@ -43,9 +43,7 @@ local type_validate = {
}
local function validate_config(config, template, check_arg)
- for _, key_template in pairs(template) do
- local key = key_template[1]
- local template_value = key_template[2]
+ for key, template_value in pairs(template) do
local value = config[key]
if not value then
if not template_value.is_optional then
@@ -83,13 +81,13 @@ local function validate_config(config, template, check_arg)
end
local replica_template = {
- {'uri', {type = 'non-empty string', name = 'URI', check = check_uri}},
- {'name', {type = 'string', name = "Name", is_optional = true}},
- {'zone', {type = {'string', 'number'}, name = "Zone", is_optional = true}},
- {'master', {
+ uri = {type = 'non-empty string', name = 'URI', check = check_uri},
+ name = {type = 'string', name = "Name", is_optional = true},
+ zone = {type = {'string', 'number'}, name = "Zone", is_optional = true},
+ master = {
type = 'boolean', name = "Master", is_optional = true, default = false,
check = check_master
- }},
+ },
}
local function check_replicas(replicas)
@@ -100,12 +98,12 @@ local function check_replicas(replicas)
end
local replicaset_template = {
- {'replicas', {type = 'table', name = 'Replicas', check = check_replicas}},
- {'weight', {
+ replicas = {type = 'table', name = 'Replicas', check = check_replicas},
+ weight = {
type = 'non-negative number', name = 'Weight', is_optional = true,
default = 1,
- }},
- {'lock', {type = 'boolean', name = 'Lock', is_optional = true}},
+ },
+ lock = {type = 'boolean', name = 'Lock', is_optional = true},
}
--
@@ -177,50 +175,50 @@ local function check_sharding(sharding)
end
local cfg_template = {
- {'sharding', {type = 'table', name = 'Sharding', check = check_sharding}},
- {'weights', {
+ sharding = {type = 'table', name = 'Sharding', check = check_sharding},
+ weights = {
type = 'table', name = 'Weight matrix', is_optional = true,
check = cfg_check_weights
- }},
- {'shard_index', {
+ },
+ shard_index = {
type = {'non-empty string', 'non-negative integer'},
name = 'Shard index', is_optional = true, default = 'bucket_id',
- }},
- {'zone', {
+ },
+ zone = {
type = {'string', 'number'}, name = 'Zone identifier',
is_optional = true
- }},
- {'bucket_count', {
+ },
+ bucket_count = {
type = 'positive integer', name = 'Bucket count', is_optional = true,
default = consts.DEFAULT_BUCKET_COUNT
- }},
- {'rebalancer_disbalance_threshold', {
+ },
+ rebalancer_disbalance_threshold = {
type = 'non-negative number', name = 'Rebalancer disbalance threshold',
is_optional = true,
default = consts.DEFAULT_REBALANCER_DISBALANCE_THRESHOLD
- }},
- {'rebalancer_max_receiving', {
+ },
+ rebalancer_max_receiving = {
type = 'positive integer',
name = 'Rebalancer max receiving bucket count', is_optional = true,
default = consts.DEFAULT_REBALANCER_MAX_RECEIVING
- }},
- {'collect_bucket_garbage_interval', {
+ },
+ collect_bucket_garbage_interval = {
type = 'positive number', name = 'Garbage bucket collect interval',
is_optional = true,
default = consts.DEFAULT_COLLECT_BUCKET_GARBAGE_INTERVAL
- }},
- {'collect_lua_garbage', {
+ },
+ collect_lua_garbage = {
type = 'boolean', name = 'Garbage Lua collect necessity',
is_optional = true, default = false
- }},
- {'sync_timeout', {
+ },
+ sync_timeout = {
type = 'non-negative number', name = 'Sync timeout', is_optional = true,
default = consts.DEFAULT_SYNC_TIMEOUT
- }},
- {'connection_outdate_delay', {
+ },
+ connection_outdate_delay = {
type = 'non-negative number', name = 'Object outdate timeout',
is_optional = true
- }},
+ },
}
--
--
2.14.1
next prev parent reply other threads:[~2018-08-03 20:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 16:25 [tarantool-patches] [PATCH 0/3] multiple routers AKhatskevich
2018-07-31 16:25 ` [tarantool-patches] [PATCH 1/3] Update only vshard part of a cfg on reload AKhatskevich
2018-08-01 18:43 ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-03 20:03 ` Alex Khatskevich
2018-08-06 17:03 ` Vladislav Shpilevoy
2018-08-07 13:19 ` Alex Khatskevich
2018-08-08 11:17 ` Vladislav Shpilevoy
2018-07-31 16:25 ` [tarantool-patches] [PATCH 2/3] Move lua gc to a dedicated module AKhatskevich
2018-08-01 18:43 ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-03 20:04 ` Alex Khatskevich
2018-08-06 17:03 ` Vladislav Shpilevoy
2018-08-08 11:17 ` Vladislav Shpilevoy
2018-07-31 16:25 ` [tarantool-patches] [PATCH 3/3] Introduce multiple routers feature AKhatskevich
2018-08-01 18:43 ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-03 20:05 ` Alex Khatskevich
2018-08-06 17:03 ` Vladislav Shpilevoy
2018-08-07 13:18 ` Alex Khatskevich
2018-08-08 12:28 ` Vladislav Shpilevoy
2018-08-08 14:04 ` Alex Khatskevich
2018-08-08 15:37 ` Vladislav Shpilevoy
2018-08-01 14:30 ` [tarantool-patches] [PATCH] Check self arg passed for router objects AKhatskevich
2018-08-03 20:07 ` AKhatskevich [this message]
2018-08-06 15:49 ` [tarantool-patches] Re: [PATCH] Refactor config templates Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180803200744.18515-1-avkhatskevich@tarantool.org \
--to=avkhatskevich@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [tarantool-patches] [PATCH] Refactor config templates' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox