question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Struct-valued constants are not yet implemented

See original GitHub issue

As it stands today, the current thrifty schema is not able to parse struct valued constants. Wanted to know if this is a work in progress? If not, was this something consciously left out from implementation?

I am trying to load schemas for manipulating certain exceptions based on added annotations. Given that we only care about exceptions structs, is it possible to silently fail the constant schema generation so that it does not throw IllegalStateException?

Several of our thrift definitions have struct valued constants so wondering if there is any workaround?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janarajancommented, Apr 7, 2022

Thanks, @benjamin-bader for the pointers. The apache compiler does support it as we have plenty of struct-defined constants and use the generated code. I am taking a stab at the Loader to see if I can add a ConstValidator implementation for struct valued constants. The AntlrThrift.g4 has support for loading the struct valued constant as the grammar is in line with what Thrift grammar has.

AntlrThrift.g4

constDef : 'const' fieldType IDENTIFIER '=' constValue separator? ;

https://thrift.apache.org/docs/idl#const

Const ::= 'const' FieldType Identifier '=' ConstValue ListSeparator?

I will leave out the code gen part at this time as the immediate requirement is to be able to load the schema.

0reactions
benjamin-badercommented, Apr 7, 2022

Nice, I’ll look forward to it! It’s been so long since I’ve worked on the schema project that I completely forgot that we absolutely did intend to do this. Turns out we never had the need so it fell off my radar.

You’re right that ConstValidator is where the work needs to happen; sounds like you’ve already figured out everything you need. Let me know how I can help, if you hit any issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

suboptimal compilation of struct-valued switch statements ...
The integer constant cases are implemented as a binary search; the struct cases are implemented as linear search.
Read more >
Why is the Copy trait needed for default (struct valued) array ...
Copy does not contain methods; it exists solely to mark that implementing types have certain property and so it is usually called a...
Read more >
Compile-Time Constant Expressions for Swift
Chris Lattner and I have been working on a proposal to add compile-time constant expressions to Swift. Our goal is to create a...
Read more >
Java-centric foreign metadata - Community Code Review
Extracted interfaces can be implemented directly for maximum performance. ... Fields will not be used to model constant values. Java interface subtyping ...
Read more >
C++ Serialization - Cap'n Proto
Other compilers have not been tested at this time. This implementation prefers to handle errors using exceptions. Exceptions are only used in circumstances ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found