Hi
24.03.2015, 07:49, "Vasaka Funarg" <
vas...@gmail.com>:
> In C++ example in elliptics project you use session to post reply
>
> elliptics::exec_context context = elliptics::exec_context::from_raw(chunks[0].c_str(), chunks[0].size());
>
> COCAINE_LOG_INFO(log, "echo: event: %s, data-size: %ld", event.c_str(), context.data().size());
>
> elliptics::async_reply_result result = reply_client->reply(context, context.data(), elliptics::exec_context::final);
> result.connect(std::bind(noop_function, response));
>
> what you suggest here is sending reply with response object, what is the difference between approaches?
Apparently python code doesn't work out of the box.
C++ code sends reply not via cocaine object, but via elliptics - it is required to build a chain of handlers,
consider the case when you send event 'event@app1', its handler sends event to 'event@app2' it sends
event to 'final@app3' and you want original client to get all results from all handlers.
Since handlers may not know about the chain, I introduced sph header, it contains 'address' (ID actually)
of the first node in the chain ('event@app1' in our example), you can only send data to elliptics via elliptics protocol,
hence there is elliptics_client->reply(sph, some data).
Cocaine protocol only allows you to implement request-response scheme without event chaining.
I will this about python reply implementation, it is broken now, so you can only use C++ to send replies back to client from event handlers.