Probably not *ideal* but depending on your client language, you could "Monkey 
Patch" the generated thrift class, so that it accepts named parameters and then 
populates the appropriate fields in the struct before sending it to the server. 
 I attached a straight forward and idiomatic example in Ruby.  If Thrift 
supported some sort of annotation mechanism, you could specify the named 
parameter to struct transformation in the IDL.

Michael

________________________________
From: Matthieu Imbert <[email protected]>
Reply-To: <[email protected]>
Date: Wed, 1 Jul 2009 11:14:29 -0700
To: <[email protected]>
Subject: Re: optional fields in function declaration

Bryan Duxbury wrote:
> I would say that there's no question it would be useful. However, I'm
> not sure how that would translate to all client languages.
>
> A completely safe and reliable way to simulate this would be to make a
> new struct for your method that has optional fields and just use that as
> the only parameter to the method. Does that make sense?

Yes, i'm already doing this and it works great. The only two drawbacks
is that you end up with a lot of structs if you have lots of functions
with optional parameters, and of course the client API is not as simple
and straightforward to use.

--
Matthieu

Reply via email to