-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document box.session.push() and IPROTO_CHUNK code #538
Comments
@pgulutzan Please, document that |
The net.box part (using is_async + :pairs()) was not documented. https://tarantool.io/en/doc/1.10/reference/reference_lua/net_box/#net-box-is-async |
I added one sentence: |
I don't see IPROTO_CHUNK and overall out of bound responses description in the binary protocol documentation. |
@Totktonada: IPROTO_CHUNK and out-of-band responses description is in https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_session/push/ and there are references to that in https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/ and in https://www.tarantool.io/en/doc/latest/dev_guide/reference_capi/box/#c.box_session_push . Would it satisfy you if a binary protocol "responses" section contained a reference to that as well? |
@pgulutzan Sorry, but, it seems, no. Can we describe the binary protocol in the binary protocol article and Lua API in the box.session.push() API description? I don't see a reason to describe things in irrelevant sections. Why it worth to describe things in the relevant sections? For example, when you use Lua API it does not matter what is binary protocol code. |
@Totktonada: I thought that what I was proposing was the same as what you're requesting, but perhaps I caused misunderstanding by leaving out details. I will propose the same thing again, with details.
|
@pgulutzan It seems, now we understood each other.
|
Remaining scope:
Document IPROTO_CHUNK and overall out of bound responses description in the binary protocol documentation.
box.session.push
is the API to send out of bound responses. Actually it is API for server -> client streaming.To get the second parameter -
sync
you should at the beginning of the request save result ofbox.session.sync()
into a local variable, and use the saved value as the second push argument.When the session is binary, the data is sent with the same sync as the request using
IPROTO_CHUNK = 128
code in the packet header. When the session is text, YAML tag is used for pushed data:%TAG !push! tag:tarantool.io/push,2018
, and on the client side the message is just printed to the stdout.Netbox supports pushes in two ways.
For any sync request (DML, call, eval - no matter) you can specify two options:
on_push
andon_push_ctx
. When in the scope of the request a push message is received,on_push
is called ason_push(on_push_ctx, new_message)
.For async request (when
is_async
option is set andtrue
) you can not specifyon_push_[ctx]
, but can iterate over messages using this syntax:Here
pairs
takes one optional argument - timeout per iteration. If no a new message or the final response during this timeout, the error is returned to the cycle. To check for an error a one can usei
- the first loop parameter above. Ifi == nil
(actually it isbox.NULL
- purenil
can not be returned as a loop key due to Lua language limitations) thenmessage
is actually the error object. You can check its type and error code like for any Tarantool error. For details seemessage:unpack()
. After an error the iteration is stopped.Requested by @Gerold103 in tarantool/tarantool#2677.
The text was updated successfully, but these errors were encountered: