Rework whole package structure (improved dependency handling)

This commit is contained in:
Kristóf Tóth
2019-07-24 15:17:16 +02:00
parent c6e01d294d
commit a23224aced
72 changed files with 74 additions and 75 deletions

View File

@ -1,3 +1,4 @@
from .tfw_connector import TFWUplinkConnector, TFWConnector
from .event_handler_factory import EventHandlerFactory
from .signal_handling import setup_signal_handlers
from .tfw_server import TFWServer

View File

@ -1,4 +1,4 @@
from tfw.event_handlers import EventHandlerFactoryBase
from tfw.internals.event_handling import EventHandlerFactoryBase
from .tfw_connector import TFWConnector

View File

@ -1,6 +1,6 @@
from signal import signal, SIGTERM, SIGINT
from tfw.event_handlers import EventHandler
from tfw.internals.event_handling import EventHandler
def setup_signal_handlers():

View File

@ -1,4 +1,4 @@
from tfw.networking import ServerConnector, ServerUplinkConnector
from tfw.internals.networking import ServerConnector, ServerUplinkConnector
from tfw.config import TFWENV

View File

@ -0,0 +1,31 @@
import logging
from tornado.web import Application
from tfw.internals.networking import EventHandlerConnector
from tfw.internals.server import ZMQWebSocketRouter
from tfw.config import TFWENV
LOG = logging.getLogger(__name__)
class TFWServer:
"""
This class handles the proxying of messages between the frontend and event handers.
It proxies messages from the "/ws" route to all event handlers subscribed to a ZMQ
SUB socket.
"""
def __init__(self):
self._event_handler_connector = EventHandlerConnector(
downlink_bind_addr=f'tcp://*:{TFWENV.PULL_PORT}',
uplink_bind_addr=f'tcp://*:{TFWENV.PUB_PORT}'
)
self.application = Application([(
r'/ws', ZMQWebSocketRouter, {
'event_handler_connector': self._event_handler_connector,
}
)])
def listen(self):
self.application.listen(TFWENV.WEB_PORT)