Add --num-threads option to query-cloudwatch#9444
Conversation
**Why**: Option to increase parallelism changelog: Internal, Scripts, Add --num-threads option to query-cloudwatch
| '--num-threads NUM', | ||
| "number of threads, defaults to #{Reporting::CloudwatchClient::DEFAULT_NUM_THREADS}", | ||
| ) do |str| | ||
| config.num_threads = Integer(str, 10) |
There was a problem hiding this comment.
Asking out of curiosity: is there a reason we explicitly specify that this is base 10 (the second argument)? I see mixed use in the project. AFAICT the default if not specified is base 10; any other behavior would feel very surprising.
I have no objection at all to including it; I'm just curious if there's a fun story here or if it's just a pattern we use on the project.
There was a problem hiding this comment.
Oh, fun, disregard! I answered my own question with an example of my childhood ZIP code:
[12] pry(main)> Integer("03054")
=> 1580
[13] pry(main)> Integer("03054", 10)
=> 3054
This interpretation was one of my first surprises years ago when I first started working with Ruby. (Also also a good lesson in ZIP codes being strings, not integers.)
There was a problem hiding this comment.
The Integer() method returns wrong results with leading zeroes, so this is about strictness. And I chose Integer over .to_i because .to_i but that silently returns 0 with non-numeric things, but Integer will raise
Integer('077') # unexpected value, bad
=> 63
Integer('077', 10) # right value, good
=> 77
> Integer('a', 10) # should error, good
(irb):6:in `Integer': invalid value for Integer(): "a" (ArgumentError)
> "a".to_i # won't error, bad
=> 0
Leftover from pairing on LG-11381