Skip to content
Snippets Groups Projects
Commit 58e8773d authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

iproto: generate iproto_type_strs from IPROTO_TYPES

Currently, we fill iproto_type_strs only for command codes exported to
box.stat while for the rest of command codes we have a switch-case in
the iproto_type_name function. This is ugly and error-prone because we
can easily forget to update iproto_type_name when we add a new command
code. Let's generate iproto_type_strs automatically just like we
generate iproto_key_strs.

There are a few things that should be noted here:
 - We don't generate strings for IPROTO_TYPE_ERROR and IPROTO_UNKNOWN
   because the former has a big code while the latter has a negative
   code. The only place where we need the strings is exporting IPROTO
   constants to Lua so now we just export these special codes explicitly
   there.
 - We don't generate strings for IPROTO codes reserved for vinyl because
   they aren't exported to Lua and use a different naming convention.
   As before, we have a switch-case in iproto_type_name for them.
 - We remove IPROTO_RESERVED_TYPE_STAT_MAX because it isn't a reserved
   code. Instead we define IPROTO_TYPE_STAT_MAX explicitly in the
   iproto_type enum as IPROTO_ROLLBACK + 1. This allows us to remove
   the condition that skips "RESERVED" constants from the code that
   exports IPROTO constants to Lua.
 - Before this change iproto_type_strs didn't have names for OK,
   CALL_16, and NOP, because they aren't shown in box.stat. After this
   change the names are present so we have to filter out the stat items
   explicitly in the rmean_foreach callback.

Generating iproto_type_strs makes iproto_type_constants useless so we
drop it in the scope of this patch and start using iproto_type_strs
to populate box.iproto.type.

Follow-up #8443
Follow-up commit b3fb883b ("iproto: export IPROTO constants to Lua
automatically")

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring

(cherry picked from commit 42dc000e)
parent a052c10b
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment