mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-06-29 02:25:11 +00:00
Further improve EventHandler <-> EventHandlerBase port situation
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
from tfw.event_handlers import EventHandlerBase
|
||||
from tfw.networking import Scope
|
||||
|
||||
from .tfw_server_connector import TFWServerConnector
|
||||
|
||||
|
||||
class EventHandler(EventHandlerBase):
|
||||
# pylint: disable=abstract-method
|
||||
def __init__(self, key, scope=Scope.ZMQ):
|
||||
super().__init__(key, TFWServerConnector(), scope=scope)
|
||||
def _build_server_connector(self):
|
||||
return TFWServerConnector()
|
||||
|
@ -1,12 +1,10 @@
|
||||
from abc import ABC
|
||||
|
||||
from tfw.components import FSMAware
|
||||
from tfw.networking import Scope
|
||||
|
||||
from .event_handler import EventHandler
|
||||
|
||||
|
||||
class FSMAwareEventHandler(EventHandler, FSMAware, ABC):
|
||||
class FSMAwareEventHandler(EventHandler, FSMAware):
|
||||
# pylint: disable=abstract-method
|
||||
"""
|
||||
Abstract base class for EventHandlers which automatically
|
||||
|
@ -1,19 +1,25 @@
|
||||
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}'
|
||||
class ConnAddrMixin:
|
||||
@property
|
||||
def uplink_conn_addr(self):
|
||||
return f'tcp://localhost:{TFWENV.PULL_PORT}'
|
||||
|
||||
@property
|
||||
def downlink_conn_addr(self):
|
||||
return 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
|
||||
)
|
||||
class TFWServerUplinkConnector(ServerUplinkConnector, ConnAddrMixin):
|
||||
def __init__(self):
|
||||
super().__init__(self.uplink_conn_addr)
|
||||
|
||||
|
||||
class TFWServerConnector(ServerConnector, ConnAddrMixin):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
self.downlink_conn_addr,
|
||||
self.uplink_conn_addr
|
||||
)
|
||||
|
Reference in New Issue
Block a user