This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
producer/consumerinformation.py

38 lines
1000 B
Python

#!/usr/bin/env python
"""
Consumer locator module, that manages the list of consumers.
"""
from redisconnector import RedisConnector
__author__ = "@ricsik52"
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
__module_name__ = "consumerlocator"
__version__text__ = "1"
class ConsumerInformation:
"""
Component responsible for providing high level information about consumers
"""
def __init__(self, redisconnector: RedisConnector):
"""**Constructor:**
Initializes the object.
:param redisconnector: the :class:'redisconnector.RedisConnector' instance that will be used for Redis connection.
"""
self.red = redisconnector
def getconsumerlist(self) -> list:
"""
Gets the list of currently available consumers.
:return:
"""
toreturn = []
for consumer in self.red.consumerlist:
if consumer['State']:
toreturn.append(consumer['Host'])
return toreturn