[tarantool-patches] [PATCH 0/5] session: introduce box.session.push
v.shpilevoy at tarantool.org
v.shpilevoy at tarantool.org
Mon Mar 19 16:41:12 MSK 2018
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 at 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)
>
>
More information about the Tarantool-patches
mailing list