Discussion:
Async in thrift server
封仲淹
2017-08-01 12:58:07 UTC
Permalink
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
Feng Longda
2017-08-04 01:40:52 UTC
Permalink
Sorry for disturbing, any help are appreciated.


Thanks
Longda


---------- Forwarded message ----------
From: 封仲淹 <***@gmail.com>
Date: 2017-08-01 20:58 GMT+08:00
Subject: Async in thrift server
To: ***@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
Edward Capriolo
2017-08-04 01:54:41 UTC
Permalink
https://chamibuddhika.wordpress.com/2011/10/02/apache-thrift-quickstart-tutorial/

Thrift generates sync and async stubs for each service method.
Post by Feng Longda
Sorry for disturbing, any help are appreciated.
Thanks
Longda
---------- Forwarded message ----------
Date: 2017-08-01 20:58 GMT+08:00
Subject: 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.
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
Loading...