ngsi-timeseries-api icon indicating copy to clipboard operation
ngsi-timeseries-api copied to clipboard

Fix for Issue#518

Open daminichopra opened this issue 3 years ago • 3 comments

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

daminichopra avatar Oct 25 '21 15:10 daminichopra

CLA Assistant Lite bot All contributors have signed the CLA ✍️

github-actions[bot] avatar Oct 25 '21 15:10 github-actions[bot]

@chicco785 Gentle Reminder for merging!!

daminichopra avatar Dec 08 '21 09:12 daminichopra

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:

  1. 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 a ValueError if x is not in [a, b].
  2. 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?

c0c0n3 avatar Jan 04 '22 16:01 c0c0n3