Skip to content

Commit

Permalink
Merge pull request #59 from mmagr/timeouts
Browse files Browse the repository at this point in the history
Allows default device timeout to be configurable
  • Loading branch information
mmagr committed Apr 3, 2018
2 parents b79c9ff + ef84135 commit b4fb7bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DeviceManager/StatusMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ def notify(self, tenant, device, status):
self.producer.send(self.topic, message)

@staticmethod
def default_exp(tenant, device, exp=5):
def default_exp(tenant, device):
db.session.execute("SET search_path TO %s" % tenant)
device = db.session.query(Device).filter(Device.id == device).one()
for template in device.templates:
for attr in template.config_attrs:
if (attr.type == "meta") and (attr.label == "device_timeout"):
return int(attr.static_value)/1000.0
return exp
return CONFIG.status_timeout


def set_online(self, tenant, device, partition, exp):
Expand Down
2 changes: 2 additions & 0 deletions DeviceManager/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self,
device_subject="device-data",
redis_host="device-manager-redis",
redis_port="6379",
status_timeout="5",
create_db=True):
# Postgres configuration data
self.dbname = os.environ.get('DBNAME', db)
Expand All @@ -38,6 +39,7 @@ def __init__(self,
# Which subject to publish new device information to
self.subject = os.environ.get('SUBJECT', subject)
self.device_subject = os.environ.get('DEVICE_SUBJECT', device_subject)
self.status_timeout = int(os.environ.get('STATUS_TIMEOUT', status_timeout))

self.redis_host = os.environ.get('REDIS_HOST', redis_host)
self.redis_port = int(os.environ.get('REDIS_PORT', redis_port))
Expand Down

0 comments on commit b4fb7bc

Please sign in to comment.