Improve module dependencies by moving port envvars out of tfw.networking

This commit is contained in:
Kristóf Tóth
2019-06-04 13:58:03 +02:00
parent f151ecfbac
commit c8e98af516
14 changed files with 68 additions and 45 deletions

View File

@ -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

View File

@ -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)

View 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
)