mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-06-29 00:15:11 +00:00
Improve module dependencies by moving port envvars out of tfw.networking
This commit is contained in:
@ -5,3 +5,4 @@ from .event_handler_base import EventHandlerBase
|
||||
from .frontend_event_handler_base import FrontendEventHandlerBase
|
||||
from .boradcasting_event_handler import BroadcastingEventHandler
|
||||
from .fsm_aware_event_handler import FSMAwareEventHandler
|
||||
from .tfw_server_connector import TFWServerUplinkConnector, TFWServerConnector
|
||||
|
@ -5,9 +5,10 @@ from abc import ABC, abstractmethod
|
||||
from inspect import currentframe
|
||||
from typing import Iterable
|
||||
|
||||
from tfw.networking import ServerConnector
|
||||
from tfw.config.logs import logging
|
||||
|
||||
from .tfw_server_connector import TFWServerConnector
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -19,7 +20,7 @@ class EventHandlerBase(ABC):
|
||||
Derived classes must implement the handle_event() method
|
||||
"""
|
||||
def __init__(self, key):
|
||||
self.server_connector = ServerConnector()
|
||||
self.server_connector = TFWServerConnector()
|
||||
self.keys = []
|
||||
if isinstance(key, str):
|
||||
self.keys.append(key)
|
||||
|
19
lib/tfw/event_handlers/tfw_server_connector.py
Normal file
19
lib/tfw/event_handlers/tfw_server_connector.py
Normal file
@ -0,0 +1,19 @@
|
||||
from functools import partial
|
||||
|
||||
from tfw.networking import ServerUplinkConnector, ServerConnector
|
||||
from tfw.config import TFWENV
|
||||
|
||||
|
||||
UPLINK_CONN_ADDR = f'tcp://localhost:{TFWENV.PULL_PORT}'
|
||||
DOWNLINK_CONN_ADDR = f'tcp://localhost:{TFWENV.PUB_PORT}'
|
||||
|
||||
|
||||
TFWServerUplinkConnector = partial(
|
||||
ServerUplinkConnector,
|
||||
connect_addr=UPLINK_CONN_ADDR
|
||||
)
|
||||
TFWServerConnector = partial(
|
||||
ServerConnector,
|
||||
downlink_connect_addr=DOWNLINK_CONN_ADDR,
|
||||
uplink_connect_addr=UPLINK_CONN_ADDR
|
||||
)
|
Reference in New Issue
Block a user