Tarantool development patches archive
 help / color / mirror / Atom feed
From: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org, vdavydov.dev@gmail.com
Subject: Re: [tarantool-patches] [PATCH 1/3] netbox: allow to create a netbox connection from existing socket
Date: Thu, 22 Mar 2018 22:50:04 +0300	[thread overview]
Message-ID: <9C4A63BA-42EB-4EB6-A19C-39102FED2F0F@tarantool.org> (raw)
In-Reply-To: <20180322193312.GA18129@atlas>

[-- Attachment #1: Type: text/plain, Size: 2378 bytes --]



> 22 марта 2018 г., в 22:33, Konstantin Osipov <kostja@tarantool.org> написал(а):
> 
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org <mailto:v.shpilevoy@tarantool.org>> [18/03/22 22:18]:
> 
> The patch generally looks good to me, I can only nitpick on new
> things. 
> 
> How about renaming do_connect to connect_impl and wrap_connect to
> wrap_socket or simply wrap, or maybe bless or imbue?

Ok.

> 
>> +        if existing_connection then
>> +            connection = existing_connection
>> +            existing_connection = nil
> 
> Why is it necessary to set it to nil?

On reconnect it will call protocol_sm again, and it must no get old existing_connection again.

> 
>> +            assert(greeting)
>> +            assert(greeting.protocol ~= 'Lua console')
> 
> Please keep in mind that in Lua there are no asserts - it's a
> runtime check.

Ok.

>> +
>> +local function wrap_socket(connection, greeting, url, opts)
>> +    if connection == nil or type(greeting) ~= 'table' then
>> +        error('Usage: netbox.wrap_socket(socket, greeting, [opts])')
>> +    end
>> +    if greeting.protocol == 'Lua console' then
>> +        error('Can not wrap console socket')
>> +    end
>> +    opts = opts or {}
>> +    if not opts.user and not opts.password then
>> +        opts.user, opts.password = url.login, url.password
>> +    end
>> +    return do_connect(url.host, url.service, opts, connection, greeting)
>> +end
> 
> Looks like you should make the next step, i.e. take the piece of
> do_connect which establishes a connection and move it to
> connect(), and then you can the remains of do_connect into wrap()
> and call wrap() connect().
> 
> Did you try to do it? Had any trouble?

Connection establishment must be in connect inside create_transport, because even if an existing socket was wrapped, it still can have opts.reconnect_after option and the following scenario:
socket = ...
con = netbox.wrap_socket(socket, ..., {reconnect_after = ...})
--
-- use connection ...
--

Suppose it is broken due to error. Then netbox will try to establish a new connection after 'reconnect_after' seconds.
> 
> -- 
> Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
> http://tarantool.org <http://tarantool.org/> - www.twitter.com/kostja_osipov <http://www.twitter.com/kostja_osipov>

[-- Attachment #2: Type: text/html, Size: 19007 bytes --]

  reply	other threads:[~2018-03-22 19:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 19:17 [PATCH 0/3] console: do not use netbox for console text connections Vladislav Shpilevoy
2018-03-22 19:17 ` [PATCH 1/3] netbox: allow to create a netbox connection from existing socket Vladislav Shpilevoy
2018-03-22 19:33   ` [tarantool-patches] " Konstantin Osipov
2018-03-22 19:50     ` v.shpilevoy [this message]
2018-03-22 19:57       ` [tarantool-patches] " v.shpilevoy
2018-03-23 10:01         ` [tarantool-patches] " v.shpilevoy
2018-03-26 21:55       ` Konstantin Osipov
2018-03-22 19:17 ` [PATCH 2/3] console: do not use netbox for console text connections Vladislav Shpilevoy
2018-03-22 19:36   ` [tarantool-patches] " Konstantin Osipov
2018-03-22 19:17 ` [PATCH 3/3] netbox: deprecate console support Vladislav Shpilevoy
2018-03-22 19:37   ` [tarantool-patches] " Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9C4A63BA-42EB-4EB6-A19C-39102FED2F0F@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] [PATCH 1/3] netbox: allow to create a netbox connection from existing socket' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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