MCPcopy Create free account
hub / github.com/apache/kvrocks / ExtractFlagsFromRegisterFunction

Function ExtractFlagsFromRegisterFunction

src/storage/scripting.cc:1689–1710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1687}
1688
1689[[nodiscard]] StatusOr<ScriptFlags> ExtractFlagsFromRegisterFunction(lua_State *lua) {
1690 if (!lua_istable(lua, -1)) {
1691 return {Status::NotOK, "Expects a valid flags argument to register_function, e.g. flags={ 'no-writes' }"};
1692 }
1693 auto flag_count = static_cast<int>(lua_objlen(lua, -1));
1694 std::vector<std::string> flags_content;
1695 flags_content.reserve(flag_count);
1696 for (int i = 1; i <= flag_count; ++i) {
1697 lua_pushnumber(lua, i);
1698 lua_gettable(lua, -2);
1699 if (!lua_isstring(lua, -1)) {
1700 return {Status::NotOK, "Expects a valid flags argument to register_function, e.g. flags={ 'no-writes' }"};
1701 }
1702 flags_content.emplace_back(lua_tostring(lua, -1));
1703 // pop up the current flag
1704 lua_pop(lua, 1);
1705 }
1706 // pop up the corresponding table of the flags parameter
1707 lua_pop(lua, 1);
1708
1709 return GetFlagsFromStrings(flags_content);
1710}
1711
1712void RemoveFromRegistry(lua_State *lua, const char *name) {
1713 lua_pushstring(lua, name);

Callers 1

RedisRegisterFunctionFunction · 0.85

Calls 1

GetFlagsFromStringsFunction · 0.85

Tested by

no test coverage detected