You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Steve Angelovich <SA...@lgc.com> on 2011/07/26 17:32:39 UTC

Thrift Service question

All,

Is there a technique or pattern to be able to associate some piece of 
state information in the server with a specific client connection?  How 
are others handling this problem?

I've been able to structure almost all my services so no state on the 
server is required but I have one case where want to be able to 
associate some information with a specific client.

Thanks,
Steve

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Re: Thrift Service question

Posted by Matthieu Imbert <ma...@ens-lyon.fr>.
On 07/26/2011 05:32 PM, Steve Angelovich wrote:
> All,
>
> Is there a technique or pattern to be able to associate some piece of
> state information in the server with a specific client connection?  How
> are others handling this problem?
>
> I've been able to structure almost all my services so no state on the
> server is required but I have one case where want to be able to
> associate some information with a specific client.
>
> Thanks,
> Steve

Hi,

 From what I have understood, doing this is against thrift's design 
principles, which are that thrift services are stateless.

Even though i agree with this principle, i nevertheless had to do the 
same thing as you. In my case, the server code is in twisted python. 
Normally, one thrift handler is instanciated, which serves all 
connexions. I inherited a custom Thrift server protocol from 
TTwisted.ThriftServerProtocol in which i redefine the connectionMade 
method to instanciate a thrift handler *per connexion*.

All this is really twisted / thrift specific and is quite a hack but it 
works. I don't know if you can do it in other languages or even in 
regular python thrift. I can give you more details (or send you code 
example) if you need so.

cheers,

-- 
Matthieu

Re: Thrift Service question

Posted by Chiku Singh <ha...@gmail.com>.
How about updating the thrift file itself with an optional field. This
optional field can be read at the Server level if it is present to associate
the state with certain client connection...

On Thu, Jul 28, 2011 at 12:34 AM, Diwaker Gupta <di...@maginatics.com>wrote:

> Steve,
>
> You can achieve this fairly easily by using netty-tools
> (https://github.com/cgbystrom/netty-tools) -- you can provide your own
> handler for when a client connection is received and do whatever state
> association you need to do in the handler.
>
> Diwaker
>
> On Tue, Jul 26, 2011 at 8:32 AM, Steve Angelovich <SA...@lgc.com>
> wrote:
> > All,
> >
> > Is there a technique or pattern to be able to associate some piece of
> > state information in the server with a specific client connection?  How
> > are others handling this problem?
> >
> > I've been able to structure almost all my services so no state on the
> > server is required but I have one case where want to be able to
> > associate some information with a specific client.
> >
> > Thanks,
> > Steve
> >
> > ----------------------------------------------------------------------
> > This e-mail, including any attached files, may contain confidential and
> privileged information for the sole use of the intended recipient.  Any
> review, use, distribution, or disclosure by others is strictly prohibited.
>  If you are not the intended recipient (or authorized to receive information
> for the intended recipient), please contact the sender by reply e-mail and
> delete all copies of this message.
> >
>

Re: Thrift Service question

Posted by Diwaker Gupta <di...@maginatics.com>.
Steve,

You can achieve this fairly easily by using netty-tools
(https://github.com/cgbystrom/netty-tools) -- you can provide your own
handler for when a client connection is received and do whatever state
association you need to do in the handler.

Diwaker

On Tue, Jul 26, 2011 at 8:32 AM, Steve Angelovich <SA...@lgc.com> wrote:
> All,
>
> Is there a technique or pattern to be able to associate some piece of
> state information in the server with a specific client connection?  How
> are others handling this problem?
>
> I've been able to structure almost all my services so no state on the
> server is required but I have one case where want to be able to
> associate some information with a specific client.
>
> Thanks,
> Steve
>
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.
>

Re: Thrift Service question

Posted by Matthieu Imbert <ma...@inria.fr>.
On 07/26/2011 05:32 PM, Steve Angelovich wrote:
> All,
>
> Is there a technique or pattern to be able to associate some piece of
> state information in the server with a specific client connection?  How
> are others handling this problem?
>
> I've been able to structure almost all my services so no state on the
> server is required but I have one case where want to be able to
> associate some information with a specific client.
>
> Thanks,
> Steve

Hi,

 From what I have understood, doing this is against thrift's design 
principles, which are that thrift services are stateless.

Even though i agree with this principle, i nevertheless had to do the 
same thing as you. In my case, the server code is in twisted python. 
Normally, one thrift handler is instanciated, which serves all 
connexions. I inherited a custom Thrift server protocol from 
TTwisted.ThriftServerProtocol in which i redefine the connectionMade 
method to instanciate a thrift handler *per connexion*.

All this is really twisted / thrift specific and is quite a hack but it 
works. I don't know if you can do it in other languages or even in 
regular python thrift. I can give you more details (or send you code 
example) if you need so.

cheers,

-- 
Matthieu