Skip to content

Commit 606e50c

Browse files
committed
net.box: resolve IPROTO feature names using box.iproto.feature
Drop the IPROTO_FEATURE_NAMES table and use box.iproto.feature in iproto_feature_resolve so that we don't have to update it manually every time we add a new feature. Follow-up tarantool#8443 Follow-up commit b3fb883 ("iproto: export IPROTO constants to Lua automatically") NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
1 parent 7563213 commit 606e50c

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/box/lua/net_box.lua

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ local M_SELECT_FETCH_POS = 19
5151
-- Injects raw data into connection. Used by tests.
5252
local M_INJECT = 20
5353

54-
-- IPROTO feature id -> name
55-
local IPROTO_FEATURE_NAMES = {
56-
[0] = 'streams',
57-
[1] = 'transactions',
58-
[2] = 'error_extension',
59-
[3] = 'watchers',
60-
[4] = 'pagination',
61-
[5] = 'space_and_index_names',
62-
}
63-
6454
local REQUEST_OPTION_TYPES = {
6555
is_async = "boolean",
6656
iterator = "string",
@@ -104,13 +94,15 @@ local CONNECT_OPTION_TYPES = {
10494
-- Given an array of IPROTO feature ids, returns a map {feature_name: bool}.
10595
local function iproto_features_resolve(feature_ids)
10696
local features = {}
107-
for _, feature_name in pairs(IPROTO_FEATURE_NAMES) do
108-
features[feature_name] = false
109-
end
110-
for _, feature_id in ipairs(feature_ids) do
111-
local feature_name = IPROTO_FEATURE_NAMES[feature_id]
112-
assert(feature_name ~= nil)
113-
features[feature_name] = true
97+
local feature_names = {}
98+
for name, id in pairs(box.iproto.feature) do
99+
features[name] = false
100+
feature_names[id] = name
101+
end
102+
for _, id in ipairs(feature_ids) do
103+
local name = feature_names[id]
104+
assert(name ~= nil)
105+
features[name] = true
114106
end
115107
return features
116108
end

0 commit comments

Comments
 (0)