ngsi-timeseries-api
ngsi-timeseries-api copied to clipboard
Fix for Issue#518
Proposed changes
Inserted a start check to verify that crate back off factor
Types of changes
What types of changes does your code introduce to the project: Put
an x
in the boxes that apply
- [ x ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist
Put an x
in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to
ask. We're here to help! This is simply a reminder of what we are going
to look for before merging your code.
- [ x ] I have read the CONTRIBUTING doc
- [ x ] I have signed the CLA
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)
- [ ] Any dependent changes have been merged and published in downstream modules
Further comments
Fix for Issue
CLA Assistant Lite bot All contributors have signed the CLA ✍️
@chicco785 Gentle Reminder for merging!!
hi @daminichopra, thanks for this. I've just looked at the crate docs
- https://crate.io/docs/python/en/latest/connect.html#backoff-factor
where they explicitly mention the backoff factor should be between 0 and 120. So we need to output a config error not a warning. I suggest we change this PR as follows:
- Implement a new config reader for float ranges, e.g.
class FloatRangeVar(Evar) ...
-
FloatRangeVar
gets instantiated with an interval[a b]
where config values are expected to be, e.g.[0, 120]
in your case. - on reading a config value
x
,FloatRangeVar
raises aValueError
ifx
is not in[a, b]
.
-
- Simply use this new config reader in the translator, e.g.
backoff_factor = ... .read(FloatRangeVar('CRATE_BACKOFF_FACTOR', 0.0, 0, 120))
This way we get to reuse the validation code in the future if we have similar env vars. What do you think? Does it make any sense?