-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tracestate module and record #607
add tracestate module and record #607
Conversation
8b13e5e
to
3005df9
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #607 +/- ##
==========================================
+ Coverage 72.26% 72.54% +0.27%
==========================================
Files 60 61 +1
Lines 1904 1923 +19
==========================================
+ Hits 1376 1395 +19
Misses 528 528
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
tracestate is now a record with members element which are validated when added to the tracestate.
3005df9
to
e4c2c10
Compare
%% for the limits and string requirements that make up the regexes | ||
-define(MAX_MEMBERS, 32). | ||
-define(KEY_MP, element(2, re:compile("^([a-z][_0-9a-z\-\*\/]{0,255})|([a-z0-9][_0-9a-z-*/]{0,240}@[a-z][_0-9a-z-*/]{0,13})$"))). | ||
-define(VALUE_MP, element(2, re:compile("^([ -+--<>-~]{0,255}[!-+--<>-~])$"))). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker here, but since you use ?KEY_MP
and ?VALUE_MP
directly in the calls, I believe the recompilation will happen every time and provide limited benefits.
I realize this is code moved from another module and not a blocker, but I wanted to point it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Should I replace it with like:
-define(VALUE_MP, {re_pattern,1,0,0,
<<69,82,67,80,152,0,0,0,16,0,0,0,1,0,0,0,255,255,255,
255,255,255,255,255,0,0,0,0,0,0,1,0,0,0,64,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,131,0,
84,27,133,0,76,0,1,110,0,0,0,0,255,239,255,223,255,
255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,104,0,0,0,255,110,0,0,0,0,254,239,255,223,255,
255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,120,0,76,25,120,0,84,0>>}).
No idea how often or what versions that would break on. Maybe rare to never?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests should catch it I imagine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true
parse_pairs([Pair | Rest], Acc) -> | ||
case split(string:trim(Pair)) of | ||
{K, V} -> | ||
case re:run(K, ?KEY_MP) =/= nomatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given what was pointed out earlier, it may make more sense to pass ?KEY_MP
and ?VALUE_MP
as parameters to this function so they're compiled once per list, particularly if there's no other caching (pdict or persistent terms) to save the easy re-compiling at each iteration.
0aa5d33
to
877866a
Compare
877866a
to
3014e30
Compare
tracestate is now a record with members element which are validated when added to the tracestate.