Skip to content

fix for issue518 #741

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- Resolved TODO at src/reporter/tests/utils.py (#692)
- Added error handling in src/wq/ql/notify.py (#673)
- NGSI-LD tenant header (#664, #669)
- insert a start check to verify that crate back off factor
is less than 120 and it does not conflict with WQ retry (#518)

### Bug fixes

Expand Down
4 changes: 2 additions & 2 deletions src/translators/crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
NGSI_LD_GEOMETRY, TIME_INDEX, METADATA_TABLE_NAME, FIWARE_SERVICEPATH
import logging
from .crate_geo_query import from_ngsi_query
from utils.cfgreader import EnvReader, StrVar, IntVar, FloatVar
from utils.cfgreader import EnvReader, StrVar, IntVar, FloatRangeVar
from utils.connection_manager import ConnectionManager

# CRATE TYPES
Expand Down Expand Up @@ -68,7 +68,7 @@ def read_env(self, env: dict = os.environ):
mask_value=True))
# Added backoff_factor for retry interval between attempt of
# consecutive retries
self.backoff_factor = r.read(FloatVar('CRATE_BACKOFF_FACTOR', 0.0))
self.backoff_factor = r.read(FloatRangeVar(var_name='CRATE_BACKOFF_FACTOR', default_value=0.0, lo=0.0, hi=120.0))
self.active_shards = r.read(StrVar('CRATE_WAIT_ACTIVE_SHARDS', '1'))


Expand Down
14 changes: 14 additions & 0 deletions src/utils/cfgreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ def _do_read(self, rep: str) -> float:
return float(rep)


class FloatRangeVar(EVar):
def __init__(var_name, default_value, mask_value, lo, hi):
super(var_name, default_value, mask_value)
if lo <= hi:
self.lo = lo
self.hi = hi

def _do_read(self, rep: str) -> float:
value = float(rep)
if value not in range(self.lo, self.hi):
raise ValueError('value out of range: {}'.format(value))
return value


class BoolVar(EVar):
"""
An env value parsed as a boolean. It evaluates to true just in case the
Expand Down