diff --git a/consumerlocator.py b/consumerlocator.py index ad2d808..f1af3a3 100644 --- a/consumerlocator.py +++ b/consumerlocator.py @@ -19,18 +19,19 @@ class ConsumerLocator: Manages the list of consumers. """ - def __init__(self): + def __init__(self, comm: communicator.Communicator): """ Initialize class. """ self.consumerList = [{"Host": "KnownHost", "State": True, "LastOk": datetime.datetime.now()}] self.currentConsumer = self.consumerList[0]["Host"] + self.communicator = comm def learnconsumerlist(self): """" Learns the list of consumers. """ - recievedConsumerList = communicator.discoveravailableconsumers() + recievedConsumerList = self.communicator.discoveravailableconsumers() for consumer in recievedConsumerList: self.consumerList.append({"Host": consumer, "State": True, "LastOk": datetime.datetime.now()}) self.updateConsumerList() @@ -41,7 +42,7 @@ class ConsumerLocator: """ removeList = [] for consumer in self.consumerList: - if not communicator.checkconsumer(consumer["Host"]): + if not self.communicator.checkconsumer(consumer["Host"]): consumer["State"] = False if datetime.datetime.now() - consumer["LastOk"] > datetime.timedelta(hours=1): removeList.append(consumer) @@ -85,7 +86,7 @@ class ConsumerLocator: Check the consumers health. :return: True if OK, False if fail """ - if communicator.checkconsumer(self.currentConsumer["Host"]): + if self.communicator.checkconsumer(self.currentConsumer["Host"]): return True else: return False