Compare commits
No commits in common. "eff5f4191c033e73308e310392c2cbc7a1ac5f0f" and "e910d91f0642fdc308074465f131ae754341b1f8" have entirely different histories.
eff5f4191c
...
e910d91f06
2
app.py
2
app.py
@ -27,7 +27,7 @@ logging.basicConfig(
|
|||||||
)
|
)
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER", '10.69.42.1')
|
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER",'10.69.42.1')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
|
@ -15,7 +15,6 @@ __version__text__ = "1"
|
|||||||
|
|
||||||
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER",'10.69.42.1')
|
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER",'10.69.42.1')
|
||||||
|
|
||||||
|
|
||||||
class ConsumerLocator:
|
class ConsumerLocator:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import redis
|
|
||||||
import json
|
|
||||||
|
|
||||||
"""
|
|
||||||
Redis interaction
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "@tormakris"
|
|
||||||
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
|
||||||
__module_name__ = "redis"
|
|
||||||
__version__text__ = "1"
|
|
||||||
|
|
||||||
|
|
||||||
REDISHOST = os.getenv("PRODUCER_REDIS", 'localhost')
|
|
||||||
|
|
||||||
|
|
||||||
class RedisConnector:
|
|
||||||
"""
|
|
||||||
Class abstracting Redis communication
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
"""
|
|
||||||
Initialize class
|
|
||||||
"""
|
|
||||||
self.redisconnection = redis.StrictRedis(host=REDISHOST, port=6379, db=0)
|
|
||||||
|
|
||||||
def get_consumerlist(self):
|
|
||||||
"""
|
|
||||||
Gets list of consumers stored in Redis.
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return json.loads(self.redisconnection.get('consumerList'))
|
|
||||||
|
|
||||||
def set_consumerlist(self, consumerlist):
|
|
||||||
"""
|
|
||||||
Sets list of consumers stored in Redis.
|
|
||||||
:param consumerlist:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
json_list = json.dumps(consumerlist)
|
|
||||||
self.redisconnection.set('consumerList', json_list)
|
|
||||||
|
|
||||||
def get_currentconsumer(self):
|
|
||||||
"""
|
|
||||||
Gets currently active consumer.
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return self.redisconnection.get('currentConsumer')
|
|
||||||
|
|
||||||
def set_currentconsumer(self, currentconsumer):
|
|
||||||
"""
|
|
||||||
Sets currently active consumer
|
|
||||||
:param currentconsumer:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
self.redisconnection.set('currentConsumer', currentconsumer)
|
|
||||||
|
|
||||||
consumerlist = property(get_consumerlist, set_consumerlist)
|
|
||||||
currentconsumer = property(get_currentconsumer, set_currentconsumer)
|
|
@ -3,4 +3,3 @@ requests
|
|||||||
pytest
|
pytest
|
||||||
pytest-mock
|
pytest-mock
|
||||||
pytest-httpserver
|
pytest-httpserver
|
||||||
redis
|
|
Reference in New Issue
Block a user