Added logging about failover
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-04-22 03:59:34 +02:00
parent 49d686a4ec
commit 8a5f9efd08

View File

@ -8,6 +8,7 @@ import datetime
from communicator import Communicator
import os
from redisconnector import RedisConnector
import logging
__author__ = "@dscharnitzky"
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
@ -15,7 +16,7 @@ __module_name__ = "consumerlocator"
__version__text__ = "1"
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER", '10.69.42.1')
LOGGER = logging.getLogger(__name__)
class ConsumerLocator:
@ -59,6 +60,7 @@ class ConsumerLocator:
contains = True
if not contains:
LOGGER.info(f"Learned about new consumer at {recconsumer}")
consumer_list.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now().timestamp()})
self.red.consumerlist = consumer_list
@ -109,6 +111,7 @@ class ConsumerLocator:
self.red.currentconsumer = newcurrentconsumer
if self.red.currentconsumer is not None:
LOGGER.warning(f"Falling back to consumer at {newcurrentconsumer['Host']}")
self.learnconsumerlist()
if self.red.currentconsumer is not None: