Merge remote-tracking branch 'origin/master'
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Scharnitzky Donát 2020-03-29 16:39:02 +02:00
commit 8a1ceaebc4
5 changed files with 90 additions and 4 deletions

View File

@ -6,4 +6,4 @@ COPY . ./
RUN pip3 install --no-cache-dir -r requirements.txt
CMD ["python3" "app.py"]
CMD ["python3", "app.py"]

19
MessageSender.py Normal file
View File

@ -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)

44
communicator.py Normal file
View File

@ -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

View File

@ -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
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))

View File

@ -1 +1,2 @@
sentry_sdk
requests