You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Andrew Matheny <an...@compass.com.INVALID> on 2022/03/18 19:39:23 UTC

Generics in Thrift

Hello Thrift users,

My company is heavily invested in Thrift and would like to extend the
language to allow for more standardization across all of our APIs.  We are
particularly interested in adding support for generic structs.  For example:

template ListResourcesResponse<Resource> {
  1: optional base.ResponseStatus status;
  2: optional i32 skip;
  3: optional i32 limit;
  4: optional i32 total;
  5: optional list<Resource> results;
}

We have prototyped this by extending the parser we're using but we'd like
to explore what options are available via the community before
committing to a non-standard thrift dialect. My questions to this group
would be:
* Does anyone have any experience with something like this? Either in
generics specifically or in extending the standard grammar.
* What would be the process for updating the Apache maintained grammar to
include an additional feature like this?

Re: Generics in Thrift

Posted by Andrew Matheny <an...@compass.com.INVALID>.
Thanks Jens,

It's great to hear interest in this. I was hoping that there might be some
existing patterns to follow in terms of extending the grammar that would
fall somewhere between "do it yourself" and "add full support upstream" but
this may have been overly wishful thinking.

We are currently using custom generators driven by the alecthomas go parser
[1], so we unfortunately do not have much to share in terms of Apache
specifics. We have prototyped this by forking the parser and then using the
additions to the AST in our Go generator (using generics from 1.18).

I will sync up with my team internally and get back to you on the dev
mailing list.

Thanks!

[1]: https://github.com/alecthomas/go-thrift

On Sat, Mar 19, 2022 at 5:28 PM Jens Geyer <je...@hotmail.com> wrote:

> Hi,
>
> first I would like to move this topic to the dev list, it seems more
> appropriate.
>
> Extending the grammar and also the relevant data structures is certainly
> doable, I have little doubt about this point.
>
> However, experience shows that extending a grammar is usually only the
> first and usually also among the easier step of the process of extending
> a DSL-based code generation tool like Thrift. The more complicated
> (and/or time-consuming) pieces of the puzzle come after that. We need to
> enrich all code generators to properly support the new grammar features.
> This part may also involve writing additional code to modify the parsed
> syntax-tree before its handed over to the generators.
>
> At least to me personally the proposal sounds interesting. Since it
> seems you already invested some thoughts & time at this, as a first step
> it would be great to learn more about the general concept you have in
> mind. Also, sharing some details could help, like what you achieved
> already, what still needs to be done, etc.
>
> Have fun,
>
> JensG
>
> PS: The technical details how contribution works is explained here:
> http://thrift.apache.org/docs/HowToContribute
>
>
> Am 18.03.2022 um 20:39 schrieb Andrew Matheny:
> > Hello Thrift users,
> >
> > My company is heavily invested in Thrift and would like to extend the
> > language to allow for more standardization across all of our APIs.  We
> are
> > particularly interested in adding support for generic structs.  For
> example:
> >
> > template ListResourcesResponse<Resource> {
> >    1: optional base.ResponseStatus status;
> >    2: optional i32 skip;
> >    3: optional i32 limit;
> >    4: optional i32 total;
> >    5: optional list<Resource> results;
> > }
> >
> > We have prototyped this by extending the parser we're using but we'd like
> > to explore what options are available via the community before
> > committing to a non-standard thrift dialect. My questions to this group
> > would be:
> > * Does anyone have any experience with something like this? Either in
> > generics specifically or in extending the standard grammar.
> > * What would be the process for updating the Apache maintained grammar to
> > include an additional feature like this?
> >
>


-- 
* Andrew Matheny*
Senior Software Engineer

m: 681.285.8088

Re: Generics in Thrift

Posted by Jens Geyer <je...@hotmail.com>.
Hi,

first I would like to move this topic to the dev list, it seems more 
appropriate.

Extending the grammar and also the relevant data structures is certainly 
doable, I have little doubt about this point.

However, experience shows that extending a grammar is usually only the 
first and usually also among the easier step of the process of extending 
a DSL-based code generation tool like Thrift. The more complicated 
(and/or time-consuming) pieces of the puzzle come after that. We need to 
enrich all code generators to properly support the new grammar features. 
This part may also involve writing additional code to modify the parsed 
syntax-tree before its handed over to the generators.

At least to me personally the proposal sounds interesting. Since it 
seems you already invested some thoughts & time at this, as a first step 
it would be great to learn more about the general concept you have in 
mind. Also, sharing some details could help, like what you achieved 
already, what still needs to be done, etc.

Have fun,

JensG

PS: The technical details how contribution works is explained here: 
http://thrift.apache.org/docs/HowToContribute


Am 18.03.2022 um 20:39 schrieb Andrew Matheny:
> Hello Thrift users,
>
> My company is heavily invested in Thrift and would like to extend the
> language to allow for more standardization across all of our APIs.  We are
> particularly interested in adding support for generic structs.  For example:
>
> template ListResourcesResponse<Resource> {
>    1: optional base.ResponseStatus status;
>    2: optional i32 skip;
>    3: optional i32 limit;
>    4: optional i32 total;
>    5: optional list<Resource> results;
> }
>
> We have prototyped this by extending the parser we're using but we'd like
> to explore what options are available via the community before
> committing to a non-standard thrift dialect. My questions to this group
> would be:
> * Does anyone have any experience with something like this? Either in
> generics specifically or in extending the standard grammar.
> * What would be the process for updating the Apache maintained grammar to
> include an additional feature like this?
>

Re: Generics in Thrift

Posted by Randy Abernethy <ra...@rx-m.com>.
There are some suggestions here:
https://stackoverflow.com/questions/16845752/generic-objects-in-apache-thrift/16859156#16859156

On Fri, Mar 18, 2022 at 12:39 PM Andrew Matheny
<an...@compass.com.invalid> wrote:

> Hello Thrift users,
>
> My company is heavily invested in Thrift and would like to extend the
> language to allow for more standardization across all of our APIs.  We are
> particularly interested in adding support for generic structs.  For
> example:
>
> template ListResourcesResponse<Resource> {
>   1: optional base.ResponseStatus status;
>   2: optional i32 skip;
>   3: optional i32 limit;
>   4: optional i32 total;
>   5: optional list<Resource> results;
> }
>
> We have prototyped this by extending the parser we're using but we'd like
> to explore what options are available via the community before
> committing to a non-standard thrift dialect. My questions to this group
> would be:
> * Does anyone have any experience with something like this? Either in
> generics specifically or in extending the standard grammar.
> * What would be the process for updating the Apache maintained grammar to
> include an additional feature like this?
>


-- 

Randy Abernethy
Managing Partner
RX-M, LLCrandy.abernethy@rx-m.com
o 415-800-2922
c 415-624-6447

Re: Generics in Thrift

Posted by Jens Geyer <je...@hotmail.com>.
Hi,

first I would like to move this topic to the dev list, it seems more 
appropriate.

Extending the grammar and also the relevant data structures is certainly 
doable, I have little doubt about this point.

However, experience shows that extending a grammar is usually only the 
first and usually also among the easier step of the process of extending 
a DSL-based code generation tool like Thrift. The more complicated 
(and/or time-consuming) pieces of the puzzle come after that. We need to 
enrich all code generators to properly support the new grammar features. 
This part may also involve writing additional code to modify the parsed 
syntax-tree before its handed over to the generators.

At least to me personally the proposal sounds interesting. Since it 
seems you already invested some thoughts & time at this, as a first step 
it would be great to learn more about the general concept you have in 
mind. Also, sharing some details could help, like what you achieved 
already, what still needs to be done, etc.

Have fun,

JensG

PS: The technical details how contribution works is explained here: 
http://thrift.apache.org/docs/HowToContribute


Am 18.03.2022 um 20:39 schrieb Andrew Matheny:
> Hello Thrift users,
>
> My company is heavily invested in Thrift and would like to extend the
> language to allow for more standardization across all of our APIs.  We are
> particularly interested in adding support for generic structs.  For example:
>
> template ListResourcesResponse<Resource> {
>    1: optional base.ResponseStatus status;
>    2: optional i32 skip;
>    3: optional i32 limit;
>    4: optional i32 total;
>    5: optional list<Resource> results;
> }
>
> We have prototyped this by extending the parser we're using but we'd like
> to explore what options are available via the community before
> committing to a non-standard thrift dialect. My questions to this group
> would be:
> * Does anyone have any experience with something like this? Either in
> generics specifically or in extending the standard grammar.
> * What would be the process for updating the Apache maintained grammar to
> include an additional feature like this?
>