diff --git a/Dockerfile b/Dockerfile index a551683..0ca2e4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,4 @@ COPY . ./ RUN pip3 install --no-cache-dir -r requirements.txt -CMD ["python3" "app.py"] +CMD ["python3", "app.py"] diff --git a/MessageSender.py b/MessageSender.py new file mode 100644 index 0000000..bbdd150 --- /dev/null +++ b/MessageSender.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +import sentry_sdk +import json +import random + +class MessageSender: + data = { + "packet name" : "name", + "data" : random.randrange(100000) + } + + message = json.dumps(data) + + + +if __name__ == "__main__": + print("Producer") + message = MessageSender() + print(message.message) \ No newline at end of file diff --git a/communicator.py b/communicator.py new file mode 100644 index 0000000..4c8b585 --- /dev/null +++ b/communicator.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import requests + +""" +Main Flask RESTful API +""" + +__author__ = "@tormakris" +__copyright__ = "Copyright 2020, GoldenPogácsa Team" +__module_name__ = "messagesender" +__version__text__ = "1" + +class Communicator: + """ + Class handling low level communication with consumers. + """ + def __init__(self): + """ + Initalize class + """ + pass + + def sendmessage(self, message: str) -> None: + """ + Send message to consumer. + :param message: + :return: none + """ + pass + + def discoveravailableconsumers(self) -> list: + """ + Get the list of available consumer from the current primary consumer. + :return: + """ + pass + + def isconsumeravailable(self) -> bool: + """ + Readiness probe primary consumer. + :return: + """ + pass \ No newline at end of file diff --git a/messagesender.py b/messagesender.py index dc57c00..cd81501 100644 --- a/messagesender.py +++ b/messagesender.py @@ -1,6 +1,8 @@ #!/usr/bin/env python -#IDE JÖNNEK IMPORTOK +# IDE JÖNNEK IMPORTOK +import random +import string """ Main Flask RESTful API @@ -15,17 +17,37 @@ class MessageSender: """ Üzenetek küldéséért felelős komponens. """ + id + def __init__(self): """ Inicializálja az osztályt. """ + self.id = 0 pass - def cucc(self, szam: int, szoveg: str) -> str: + + def randomString(self, stringLength): + """Generate a random string of fixed length """ + letters = string.ascii_lowercase + return ''.join(random.choice(letters) for i in range(stringLength)) + + + def CreateMessage(self, p) -> str: """ Ez egy metodus :param szam: :param szoveg: :return: str tipus """ - pass \ No newline at end of file + self.id += random.randrange(10000) + data = self.randomString(p) + + #print(str(self.id) + " " + str(data)) + return str(self.id) + " " + str(data) + pass + + +if __name__ == "__main__": + temp = MessageSender() + print(temp.CreateMessage(20)) diff --git a/requirements.txt b/requirements.txt index 5051901..07f9470 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ sentry_sdk +requests \ No newline at end of file