You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by 封仲淹 <hu...@gmail.com> on 2017/08/01 12:58:07 UTC
Async in thrift server
Hi,
Any help are appreciated.
I want to use thrift as my RPC infrastructure, can thrift provide async mode in server side?
If thrift provide async mode in server side, could you please provide one example or quickstart for it.
For example, client send one request to server, this request will cost much i/o in server side, can server register one callback or a listener? After server finish i/o operation, thrift call the callback or listener, then send response to client in the callback or listener.
The code maybe similar as this:
Future<Response> request(Request req) {
Promise<Response> promise = Promise.of();
Event ioEvent = createEvent(req);
ioEvent.registerListener( response -> promise.success(response) );
ioThread.pushEvent(ioEvent);
return promise.getFuture();
}
But from the client, client can do like this.
Response result = client.request(req);
Thanks in advance.
Longda
Re: Async in thrift server
Posted by Edward Capriolo <ed...@gmail.com>.
https://chamibuddhika.wordpress.com/2011/10/02/apache-thrift-quickstart-tutorial/
Thrift generates sync and async stubs for each service method.
On Thu, Aug 3, 2017 at 9:40 PM, Feng Longda <hu...@gmail.com> wrote:
> Sorry for disturbing, any help are appreciated.
>
>
> Thanks
> Longda
>
>
> ---------- Forwarded message ----------
> From: 封仲淹 <hu...@gmail.com>
> Date: 2017-08-01 20:58 GMT+08:00
> Subject: Async in thrift server
> To: user@thrift.apache.org
>
>
> Hi,
>
>
>
> Any help are appreciated.
>
>
>
> I want to use thrift as my RPC infrastructure, can thrift provide
> async mode in server side?
>
> If thrift provide async mode in server side, could you please provide
> one example or quickstart for it.
>
>
>
>
>
> For example, client send one request to server, this request will cost
> much i/o in server side, can server register one callback or a
> listener? After server finish i/o operation, thrift call the callback
> or listener, then send response to client in the callback or listener.
>
>
>
> The code maybe similar as this:
>
>
>
> Future<Response> request(Request req) {
>
> Promise<Response> promise = Promise.of();
>
> Event ioEvent = createEvent(req);
>
> ioEvent.registerListener( response ->
> promise.success(response) );
>
>
>
> ioThread.pushEvent(ioEvent);
>
>
>
> return promise.getFuture();
>
> }
>
>
>
> But from the client, client can do like this.
>
>
>
> Response result = client.request(req);
>
>
>
>
>
> Thanks in advance.
>
> Longda
>
Fwd: Async in thrift server
Posted by Feng Longda <hu...@gmail.com>.
Sorry for disturbing, any help are appreciated.
Thanks
Longda
---------- Forwarded message ----------
From: 封仲淹 <hu...@gmail.com>
Date: 2017-08-01 20:58 GMT+08:00
Subject: Async in thrift server
To: user@thrift.apache.org
Hi,
Any help are appreciated.
I want to use thrift as my RPC infrastructure, can thrift provide
async mode in server side?
If thrift provide async mode in server side, could you please provide
one example or quickstart for it.
For example, client send one request to server, this request will cost
much i/o in server side, can server register one callback or a
listener? After server finish i/o operation, thrift call the callback
or listener, then send response to client in the callback or listener.
The code maybe similar as this:
Future<Response> request(Request req) {
Promise<Response> promise = Promise.of();
Event ioEvent = createEvent(req);
ioEvent.registerListener( response ->
promise.success(response) );
ioThread.pushEvent(ioEvent);
return promise.getFuture();
}
But from the client, client can do like this.
Response result = client.request(req);
Thanks in advance.
Longda