mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-06-29 07:35:13 +00:00
Rework whole package structure (improved dependency handling)
This commit is contained in:
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
from tfw.event_handlers import EventHandlerFactoryBase
|
||||
from tfw.internals.event_handling import EventHandlerFactoryBase
|
||||
|
||||
from .tfw_connector import TFWConnector
|
||||
|
||||
|
@ -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():
|
||||
|
@ -1,4 +1,4 @@
|
||||
from tfw.networking import ServerConnector, ServerUplinkConnector
|
||||
from tfw.internals.networking import ServerConnector, ServerUplinkConnector
|
||||
from tfw.config import TFWENV
|
||||
|
||||
|
||||
|
31
lib/tfw/main/tfw_server.py
Normal file
31
lib/tfw/main/tfw_server.py
Normal 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)
|
Reference in New Issue
Block a user