You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Christian <ch...@gmail.com> on 2015/03/15 01:25:58 UTC

Runtime annotations

Hey there,

It would be interesting for various tools to access thrift annotations at
runtime
(one could build an ORM for thrift objects, custom json serializers,
etc...).

I'm thinking that with some sort of option, eg: runtime_annotations:true,
a Map<string, string> ANNOTATIONS could be generated on structs and field
descriptors.

What do you think?

Re: Runtime annotations

Posted by Spencer Brown <sp...@bespoke.is>.
I have pretty much done this with Ruby. I imagine one could do the same with certainly Python. 

I defined an API to an underlying object store with strongly typed CRUD APIs... e.g. getMyObject, createMyObject, etc. Then I wrote a code generator in Ruby that takes the generated Ruby code from the Thrift compiler, walks through the defined types, and spits out both Thrift API definitions for the CRUD APIs, and also Ruby server implementation code for the APIs. 

You make the point that the runtime annotation format should be a defined interface to Thrift, that makes sense. My code generator is using the internals of how Thrift generates the Ruby code, and that could change in the tuture.

> On Mar 14, 2015, at 7:25 PM, Christian <ch...@gmail.com> wrote:
> 
> Hey there,
> 
> It would be interesting for various tools to access thrift annotations at
> runtime
> (one could build an ORM for thrift objects, custom json serializers,
> etc...).
> 
> I'm thinking that with some sort of option, eg: runtime_annotations:true,
> a Map<string, string> ANNOTATIONS could be generated on structs and field
> descriptors.
> 
> What do you think?