[ 
https://issues.apache.org/jira/browse/THRIFT-5708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17724842#comment-17724842
 ] 

Lee Yun edited comment on THRIFT-5708 at 5/22/23 9:19 AM:
----------------------------------------------------------

[~fishywang] Thank you for your reply. The main benefit of protobuf reflection, 
in my opinion, is the ability to access some IDL descriptors and retrieve 
metadata. I would like to have similar capabilities in thrift, for example, 
defining a series of descriptors such as StructDescriptor, FieldDescriptor, and 
EnumDescriptor in thrift IDL, so that the generated structure by thrift can 
retrieve these descriptors and access some IDL information, such as annotations.

Moreover, with these descriptors, we could combine them with Golang's native 
reflect API to create some convenient encapsulation and combination for 
reflection calls in Golang. This doesn't require any modification to the 
Golang's reflection library.


was (Author: JIRAUSER300251):
[~fishywang] Thank you for your reply. The main benefit of protobuf reflection, 
in my opinion, is the ability to access some IDL descriptors and retrieve 
metadata. I would like to have similar capabilities in thrift, for example, 
defining a series of descriptors such as StructDescriptor, FieldDescriptor, and 
EnumDescriptor in thrift IDL, so that the generated structure by thrift can 
retrieve these descriptors and access some IDL information, such as 
annotations. Additionally, with these descriptors, we could combine them with 
Golang's native reflect API to create some convenient encapsulation and 
combination for reflection calls in Golang.

> Support reflection capability like protobuf
> -------------------------------------------
>
>                 Key: THRIFT-5708
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5708
>             Project: Thrift
>          Issue Type: Wish
>          Components: Go - Library
>            Reporter: Lee Yun
>            Priority: Major
>
> Hello, Thrift team. I noticed that when using Protobuf, it provides 
> reflection capabilities that allow us to access metadata and use reflection 
> in generated code, like this:
> ```
> msg := pbdemo.Request\{Name: "abc"}
> m := msg.ProtoReflect()
> fds := m.Descriptor().Fields()
> fmt.Println("----- newReflect:")
> for k := 0; k < fds.Len(); k++ {
>    fd := fds.Get(k)
>    fmt.Println(fd)
> }
>  
> ```
> I'm wondering if Thrift can also support similar functionality? For example, 
> can Thrift record this metadata in generated code and provide reflection 
> capabilities similar to Protobuf? This would make code development more 
> flexible. Thank you for your attention.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to