Tarantool development patches archive
 help / color / mirror / Atom feed
From: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com
Subject: Re: [tarantool-patches] [PATCH 0/5] session: introduce box.session.push
Date: Mon, 19 Mar 2018 16:41:12 +0300	[thread overview]
Message-ID: <EB6ED1CF-6C65-46D7-98FF-1690AF3C4132@tarantool.org> (raw)
In-Reply-To: <cover.1521466428.git.v.shpilevoy@tarantool.org>

Sorry, forgot a description.

Box.session.push() allows to send a message to a client with no
finishing a main request. It means, that a client can split a big
response in several pushes, or send notifications from a long
polling request.

Tarantool now supports two push types: via text protocol and via
binary protocol. Text pushes are needed mainly for printing,
logging and all other stdout output, written on a host side from
a client console connection. Text protocol push message contains
"push:" prefix followed by a YAML formatted text, where as a final
response always has '---' prefix. To catch pushed messages client
uses console.connect() on_push option, which takes a function
with a single argument - message.

IProto message is encoded just like a regular response, but instead
of IPROTO_DATA it has IPROTO_PUSH with a single element - pushed
MessagePack encoded data.

Text push is trivial - it is just blocking write into a socket with
a prefix. Binary push is more complex.
    
TX thread to notify IProto thread about new data in obuf sends a
message 'push_msg'. IProto thread, got this message, notifies libev
about new data, and then sends 'push_msg' back with updated write
position. TX thread, received the message back, updates its version
of a write position. If IProto do not send a write position, then
TX would write to the same obuf again and again, because it can not
know that IProto already flushed another obuf.

To avoid multiple 'push_msg' in fly between IProto and TX, the only
one 'push_msg' per connection is used. To deliver pushes, appeared
when 'push_msg' was in fly, TX thread sets a flag every time when
sees, that 'push_msg' is sent, and there is a new push. When
'push_msg' returns, it checks this flag, and if it is set, then the
IProto is notified again.

> 19 марта 2018 г., в 16:34, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> написал(а):
> 
> Branch: http://github.com/tarantool/tarantool/tree/gh-2677-box-session-push
> Issue: https://github.com/tarantool/tarantool/issues/2677
> 
> Vladislav Shpilevoy (5):
>  session: forbid creation from Lua binary and applier sessions
>  lua: port console yaml formatting to C
>  Remove empty function declaration
>  session: introduce session_owner
>  session: introduce box.session.push
> 
> src/box/applier.cc                       |   4 +-
> src/box/authentication.cc                |   4 +-
> src/box/authentication.h                 |   3 +-
> src/box/box.cc                           |   4 +-
> src/box/box.h                            |   2 +-
> src/box/iproto.cc                        | 321 +++++++++++++++++++++++----
> src/box/iproto_constants.c               |   3 +-
> src/box/iproto_constants.h               |   8 +
> src/box/lua/call.c                       |   1 +
> src/box/lua/console.c                    |  42 ++++
> src/box/lua/console.h                    |   8 +
> src/box/lua/console.lua                  |  40 +---
> src/box/lua/net_box.c                    |  37 ++++
> src/box/lua/net_box.lua                  |  97 ++++++--
> src/box/lua/session.c                    | 252 ++++++++++++++++++++-
> src/box/port.c                           |   7 +
> src/box/port.h                           |  15 ++
> src/box/session.cc                       |  86 +++++++-
> src/box/session.h                        | 106 +++++++--
> src/box/vinyl.c                          |   3 +-
> src/box/xrow.c                           |  40 +++-
> src/box/xrow.h                           |  26 ++-
> src/fio.c                                |  12 +
> src/fio.h                                |  16 ++
> src/lua/socket.h                         |   2 -
> test/app-tap/console.test.lua            |   9 +-
> test/box-tap/session.test.lua            |  12 +-
> test/box/net.box.result                  |   2 +-
> test/box/net.box.test.lua                |   2 +-
> test/box/push.result                     | 364 +++++++++++++++++++++++++++++++
> test/box/push.test.lua                   | 163 ++++++++++++++
> test/replication/before_replace.result   |  14 ++
> test/replication/before_replace.test.lua |  11 +
> third_party/lua-yaml/lyaml.cc            |   9 +-
> third_party/lua-yaml/lyaml.h             |   3 +
> 35 files changed, 1576 insertions(+), 152 deletions(-)
> create mode 100644 test/box/push.result
> create mode 100644 test/box/push.test.lua
> 
> -- 
> 2.14.3 (Apple Git-98)
> 
> 

      parent reply	other threads:[~2018-03-19 13:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 13:34 Vladislav Shpilevoy
2018-03-19 13:34 ` [PATCH 1/5] session: forbid creation from Lua binary and applier sessions Vladislav Shpilevoy
2018-03-20 13:20   ` Vladimir Davydov
2018-03-20 13:46     ` v.shpilevoy
2018-03-19 13:34 ` [PATCH 2/5] lua: port console yaml formatting to C Vladislav Shpilevoy
2018-03-20 17:51   ` Vladimir Davydov
2018-03-20 18:04     ` v.shpilevoy
2018-03-21  9:14       ` Vladimir Davydov
2018-03-21  9:30         ` v.shpilevoy
2018-03-19 13:34 ` [PATCH 3/5] Remove empty function declaration Vladislav Shpilevoy
2018-03-20 17:55   ` Vladimir Davydov
2018-03-20 17:57     ` [tarantool-patches] " v.shpilevoy
2018-03-21  9:16       ` Vladimir Davydov
2018-03-19 13:34 ` [PATCH 4/5] session: introduce session_owner Vladislav Shpilevoy
2018-03-20 18:29   ` Vladimir Davydov
2018-03-19 13:34 ` [PATCH 5/5] session: introduce box.session.push Vladislav Shpilevoy
2018-03-21  9:10   ` Vladimir Davydov
2018-03-21  9:30     ` [tarantool-patches] " v.shpilevoy
2018-03-21 12:25       ` Vladimir Davydov
2018-03-19 13:41 ` v.shpilevoy [this message]

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=EB6ED1CF-6C65-46D7-98FF-1690AF3C4132@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] [PATCH 0/5] session: introduce box.session.push' \
    /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