Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] Replace net.box usage with console in tarantoolctl eval
@ 2018-07-04  9:59 Serge Petrenko
  2018-07-05 11:29 ` [tarantool-patches] " Vladislav Shpilevoy
  0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2018-07-04  9:59 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Serge Petrenko

Net.box usage for console is deprecated in 1.10,
replaced it with console.

Closes: #3490
---
https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3490-tarantoolctl-replace-netbox
https://github.com/tarantool/tarantool/issues/3490

 extra/dist/tarantoolctl.in | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 507ebe8bf..463d3e0a1 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -647,13 +647,29 @@ local function stdin_isatty()
 end
 
 local function execute_remote(uri, code)
-    local remote = netbox.connect(uri, {
-        console = true, connect_timeout = TIMEOUT_INFINITY
-    })
-    if remote == nil then
-        return nil
+    local err, ret
+    console.on_start(function(self)
+        local cmd = string.format(
+            "require('console').connect('%s', { connect_timeout = %s })",
+            uri, TIMEOUT_INFINITY
+        )
+        err = self:eval(cmd)
+        err = yaml.decode(err)[1]
+        if type(err) == 'table' and err.error then
+            err = false
+        else
+            ret = self:eval(code)
+        end
+        self.running = false
+    end)
+    console.on_client_disconnect(function(self) self.running = false end)
+
+    console.start()
+
+    if not err then
+        return false
     end
-    return true, remote:eval(code)
+    return true, ret
 end
 
 local function connect()
-- 
2.15.2 (Apple Git-101.1)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-09  9:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04  9:59 [tarantool-patches] [PATCH] Replace net.box usage with console in tarantoolctl eval Serge Petrenko
2018-07-05 11:29 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-06 13:02   ` Sergey Petrenko
2018-07-09  9:53     ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox