Compare commits

..

2 Commits

Author SHA1 Message Date
96a91c4154
Merge branch 'master' of gitea:GoldenPogacsa/producer
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-17 17:01:01 +02:00
03082b346d
send uuid with message 2020-04-17 16:59:35 +02:00
2 changed files with 6 additions and 4 deletions

4
app.py
View File

@ -40,9 +40,9 @@ if __name__ == "__main__":
generateduuid = str(uuid.uuid4())
communicator = Communicator(currentconsumer=KNOWNCONSUMER, uuid=generateduuid)
LOGGER.debug(f"My uuid is {generateduuid}")
messagesender = MessageSender(communicator=communicator, uuid=generateduuid)
consumerlocator = ConsumerLocator(uuid=generateduuid, communicator=communicator,
redisconnector=RedisConnector())
messagesender = MessageSender(communicator=communicator)
redisconnector=RedisConnector())
consumerlocator.learnconsumerlist()
while True:

View File

@ -7,6 +7,7 @@ Message sender component.
import logging
import random
import string
import json
from communicator import Communicator
__author__ = "@kovacsbence"
@ -23,13 +24,14 @@ class MessageSender:
Component responsible for sending the messages. Requires an instance of :class:`communicator.Communicator`.
"""
def __init__(self, communicator: Communicator):
def __init__(self, communicator: Communicator, uuid: str):
"""**Constructor:**
Initializes the object.
:param communicator: an instance of :class:`communicator.Communicator`.
"""
self.communicator = communicator
self.uuid = uuid
def randomstring(self, stringlength: int) -> str:
"""Generate a random string of fixed length
@ -54,4 +56,4 @@ class MessageSender:
data = self.randomstring(32)
else:
data = message
self.communicator.sendmessage(data)
self.communicator.sendmessage(json.dumps({"message": data, "uuid": self.uuid}))