From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 937054696C4 for ; Sun, 12 Apr 2020 23:13:34 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 12 Apr 2020 22:13:28 +0200 Message-Id: <6c0531bc990b086f36b0c211fccd01d96d7b27fb.1586722379.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/4] feedback: move feedback code to the single file List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org 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)