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/communicator.py

50 lines
1.1 KiB
Python
Raw Normal View History

2020-03-29 15:46:00 +02:00
#!/usr/bin/env python
2020-03-29 18:26:19 +02:00
import random
2020-03-29 16:26:16 +02:00
import requests
2020-03-29 17:58:04 +02:00
from singleton import Singleton
2020-03-29 16:26:16 +02:00
2020-03-29 15:46:00 +02:00
"""
2020-03-29 16:53:50 +02:00
Communicator module
2020-03-29 15:46:00 +02:00
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
__module_name__ = "messagesender"
2020-03-29 16:26:16 +02:00
__version__text__ = "1"
2020-03-29 17:58:04 +02:00
class Communicator(Singleton):
2020-03-29 16:26:16 +02:00
"""
Class handling low level communication with consumers.
"""
def sendmessage(self, message: str) -> None:
"""
Send message to consumer.
:param message:
:return: none
"""
2020-03-29 18:26:19 +02:00
return None
2020-03-29 16:26:16 +02:00
def discoveravailableconsumers(self) -> list:
"""
Get the list of available consumer from the current primary consumer.
:return:
"""
2020-03-29 18:26:19 +02:00
return ["10.69.42.1","10.42.69.1","10.10.10.10","10.6.66.1"]
2020-03-29 16:26:16 +02:00
def isconsumeravailable(self) -> bool:
"""
Readiness probe primary consumer.
:return:
"""
2020-03-29 18:26:19 +02:00
return bool(random.getrandbits(1))
2020-03-29 16:53:50 +02:00
def checkconsumer(self, consumer: str) -> bool:
"""
Readiness probe of a prticular consumer.
:param consumer:
:return:
"""
2020-03-29 18:26:19 +02:00
return bool(random.getrandbits(1))