You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Matthieu Imbert <ma...@ens-lyon.fr> on 2009/05/15 10:35:48 UTC

sessions on top of thrift

Hi thrift users,

I want to add sessions to my thrift service. A client of the service has
to open one (or several) session(s), then all calls to the thrift
service are done in the context of the session. And sessions can be
comitted (or rollbacked) when needed, and closed when finished.

For all this, I simply declare the following functions in my service:

SessionId session_open(1: string id_client)
void session_commit(1: SessionId id_session)
void session_rollback(1: SessionId id_session)
void session_close(1: SessionId id_session)

and all other functions of my service take a SessionId as first parameter.

I would now like that sessions have a timeout. For example, a session
not used during 1 minutes would be automatically closed on the server,
in order to avoid buggy or ill-intentioned clients to consume server
resources.

My service is implemented in python, and can use one of the python
server implementations: TSimpleServer, TThreadedServer,
TThreadPoolServer, but is there a way to add this timeout limitation to
these servers?

best regards,

-- 
Matthieu Imbert

Re: sessions on top of thrift

Posted by Phillip B Oldham <ph...@gmail.com>.
On Fri, May 15, 2009 at 9:35 AM, Matthieu Imbert
<ma...@ens-lyon.fr> wrote:
> My service is implemented in python, and can use one of the python
> server implementations: TSimpleServer, TThreadedServer,
> TThreadPoolServer, but is there a way to add this timeout limitation to
> these servers?

Do it in your app code - since you're passing in the session id at
each method call, have that session stored in memcached (or similar)
for both performance and also because you can apply an expiry time to
the entry; update the entry each time a method is called so the
session stays open, and throw an exception when a request comes in
after the entry has expired.

-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01