[Tarantool-patches] [PATCH 2/4] feedback: move feedback code to the single file
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Apr 12 23:13:28 MSK 2020
Feedback daemon's code was located in two files:
box/lua/feedback_daemon.lua and box/lua/schema.lua. That makes
it harder to eliminate the daemon at cmake configuration time.
Now all its code is in one place, in feedback_daemon.lua. Disable
of the daemon's code now is a matter of excluding the Lua file
from source code.
Part of #3308
---
src/box/lua/feedback_daemon.lua | 16 ++++++++++++++++
src/box/lua/schema.lua | 17 -----------------
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua
index ad71a3fe2..95130d696 100644
--- a/src/box/lua/feedback_daemon.lua
+++ b/src/box/lua/feedback_daemon.lua
@@ -4,6 +4,7 @@ local log = require('log')
local json = require('json')
local fiber = require('fiber')
local http = require('http.client')
+local fio = require('fio')
local PREFIX = "feedback_daemon"
@@ -131,6 +132,21 @@ setmetatable(daemon, {
}
})
+box.feedback = {}
+box.feedback.save = function(file_name)
+ if type(file_name) ~= "string" then
+ error("Usage: box.feedback.save(path)")
+ end
+ local feedback = json.encode(daemon.generate_feedback())
+ local fh, err = fio.open(file_name, {'O_CREAT', 'O_RDWR', 'O_TRUNC'},
+ tonumber('0777', 8))
+ if not fh then
+ error(err)
+ end
+ fh:write(feedback)
+ fh:close()
+end
+
if box.internal == nil then
box.internal = { [PREFIX] = daemon }
else
diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua
index 85fcca562..10584494b 100644
--- a/src/box/lua/schema.lua
+++ b/src/box/lua/schema.lua
@@ -5,8 +5,6 @@ local msgpack = require('msgpack')
local msgpackffi = require('msgpackffi')
local fun = require('fun')
local log = require('log')
-local fio = require('fio')
-local json = require('json')
local buffer = require('buffer')
local session = box.session
local internal = require('box.internal')
@@ -2711,19 +2709,4 @@ end
setmetatable(box.space, { __serialize = box_space_mt })
-box.feedback = {}
-box.feedback.save = function(file_name)
- if type(file_name) ~= "string" then
- error("Usage: box.feedback.save(path)")
- end
- local feedback = json.encode(box.internal.feedback_daemon.generate_feedback())
- local fh, err = fio.open(file_name, {'O_CREAT', 'O_RDWR', 'O_TRUNC'},
- tonumber('0777', 8))
- if not fh then
- error(err)
- end
- fh:write(feedback)
- fh:close()
-end
-
box.NULL = msgpack.NULL
--
2.21.1 (Apple Git-122.3)
More information about the Tarantool-patches
mailing list