[SERVER-81397] IDL: replace kNum${enumType} with generic-friendly trait Created: 24/Sep/23  Updated: 29/Oct/23  Resolved: 27/Sep/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-81394 replace `invariant` etc uses of boost... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2023-10-02
Participants:

 Description   

In researching SERVER-81394 (targeting Boost.Preprocessor usage specifically), I found a very heavy Boost.Preprocessor macro system to implement sophisticated macro system for resharding metrics. I mean it's really an achievement in its own right. However, it immediately occurred to me that this was a workaround.

It was only really necessary because of an IDL generator problem. We must use preprocessor token-stitching to produce the name of a trait of an IDL-generated enum trait kNum##name for the enum name. If we make a very small change to IDL, we can just specialize a trait e.g. idlEnumCount<name> instead, and vastly simplify the resharding metrics registration code I encountered. And we'd unlock other beneficial uses in code for teams that aren't currently in a position to put that much engineering time into a workaround.

And it's a very small and simple change! We don't really use this trait much.



 Comments   
Comment by Githook User [ 27/Sep/23 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-81397 add generic-friendly alternative idlEnumCount<Foo>, remove kNumFoo

enumSizeForCumulativeMetrics
Branch: master
https://github.com/mongodb/mongo/commit/191ec34eca0a9ee072c1ba619d3bbdea4e6dab1f

Generated at Thu Feb 08 06:46:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.