communicator requests api implementation done
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-29 20:00:27 +02:00
parent 06671e29b8
commit fe3537ff31
4 changed files with 72 additions and 77 deletions

40
app.py
View File

@@ -1,12 +1,16 @@
#!/usr/bin/env python
import random
import time
import uuid
import logging
import sentry_sdk
import communicator
import consumerlocator
import messagesender
from communicator import Communicator
from consumerlocator import ConsumerLocator
from messagesender import MessageSender
"""
Main Flask RESTful API
Main entrypoint
"""
__author__ = "@tormakris"
@@ -16,20 +20,18 @@ __version__text__ = "1"
sentry_sdk.init("https://3fa5ae886ba1489092ad49a93cb419c1@sentry.kmlabz.com/9")
logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger(__name__)
if __name__ == "__main__":
print("Producer: init")
comm = communicator.Communicator()
conslist = consumerlocator.ConsumerLocator()
conslist.initCommunicator(comm)
message = messagesender.MessageSender()
LOGGER.info("Producer started")
generateduuid = str(uuid)
LOGGER.debug(f"My uuid is {generateduuid}")
consumerlocator = ConsumerLocator()
communicator = Communicator(consumerlocator=consumerlocator,uuid=uuid)
messagesender = MessageSender(communicator=communicator)
conslist.learnconsumerlist()
print("Producer: started sending")
for i in range(30):
print("Producer: send %i message", i)
msg = message.CreateMessage(20)
if not conslist.checkcurrentconsumer():
conslist.updateconsumer()
comm.sendmessage(msg)
print("Producer: finished")
while True:
LOGGER.info("Sending message to consumer")
messagesender.sendmessage()
time.sleep(random.random())