38 lines
1000 B
Python
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
|