mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-12 19:27:17 +00:00
Remove ZMQConnectorBase
This commit is contained in:
parent
82df8a8065
commit
e44a99fa6d
@ -8,15 +8,13 @@ from tfw.config import TFWENV
|
|||||||
from tfw.config.logs import logging
|
from tfw.config.logs import logging
|
||||||
|
|
||||||
from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg
|
from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg
|
||||||
from .zmq_connector_base import ZMQConnectorBase
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
class EventHandlerDownlinkConnector():
|
||||||
def __init__(self, zmq_context=None):
|
def __init__(self):
|
||||||
super(EventHandlerDownlinkConnector, self).__init__(zmq_context)
|
self._zmq_pull_socket = zmq.Context.instance().socket(zmq.PULL)
|
||||||
self._zmq_pull_socket = self._zmq_context.socket(zmq.PULL)
|
|
||||||
self._zmq_pull_socket.setsockopt(zmq.RCVHWM, 0)
|
self._zmq_pull_socket.setsockopt(zmq.RCVHWM, 0)
|
||||||
self._zmq_pull_stream = ZMQStream(self._zmq_pull_socket)
|
self._zmq_pull_stream = ZMQStream(self._zmq_pull_socket)
|
||||||
address = f'tcp://*:{TFWENV.RECEIVER_PORT}'
|
address = f'tcp://*:{TFWENV.RECEIVER_PORT}'
|
||||||
@ -31,10 +29,9 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
|||||||
self._zmq_pull_stream.close()
|
self._zmq_pull_stream.close()
|
||||||
|
|
||||||
|
|
||||||
class EventHandlerUplinkConnector(ZMQConnectorBase):
|
class EventHandlerUplinkConnector():
|
||||||
def __init__(self, zmq_context=None):
|
def __init__(self):
|
||||||
super(EventHandlerUplinkConnector, self).__init__(zmq_context)
|
self._zmq_pub_socket = zmq.Context.instance().socket(zmq.PUB)
|
||||||
self._zmq_pub_socket = self._zmq_context.socket(zmq.PUB)
|
|
||||||
self._zmq_pub_socket.setsockopt(zmq.SNDHWM, 0)
|
self._zmq_pub_socket.setsockopt(zmq.SNDHWM, 0)
|
||||||
address = f'tcp://*:{TFWENV.PUBLISHER_PORT}'
|
address = f'tcp://*:{TFWENV.PUBLISHER_PORT}'
|
||||||
self._zmq_pub_socket.bind(address)
|
self._zmq_pub_socket.bind(address)
|
||||||
@ -48,6 +45,10 @@ class EventHandlerUplinkConnector(ZMQConnectorBase):
|
|||||||
|
|
||||||
|
|
||||||
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
|
class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector):
|
||||||
|
def __init__(self):
|
||||||
|
EventHandlerDownlinkConnector.__init__(self)
|
||||||
|
EventHandlerUplinkConnector.__init__(self)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
EventHandlerDownlinkConnector.close(self)
|
EventHandlerDownlinkConnector.close(self)
|
||||||
EventHandlerUplinkConnector.close(self)
|
EventHandlerUplinkConnector.close(self)
|
||||||
|
@ -11,15 +11,13 @@ from tfw.config.logs import logging
|
|||||||
|
|
||||||
from .scope import Scope
|
from .scope import Scope
|
||||||
from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg
|
from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg
|
||||||
from .zmq_connector_base import ZMQConnectorBase
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ServerDownlinkConnector(ZMQConnectorBase):
|
class ServerDownlinkConnector():
|
||||||
def __init__(self, zmq_context=None):
|
def __init__(self):
|
||||||
super(ServerDownlinkConnector, self).__init__(zmq_context)
|
self._zmq_sub_socket = zmq.Context.instance().socket(zmq.SUB)
|
||||||
self._zmq_sub_socket = self._zmq_context.socket(zmq.SUB)
|
|
||||||
self._zmq_sub_socket.connect(f'tcp://localhost:{TFWENV.PUBLISHER_PORT}')
|
self._zmq_sub_socket.connect(f'tcp://localhost:{TFWENV.PUBLISHER_PORT}')
|
||||||
self._zmq_sub_socket.setsockopt(zmq.RCVHWM, 0)
|
self._zmq_sub_socket.setsockopt(zmq.RCVHWM, 0)
|
||||||
self._zmq_sub_stream = ZMQStream(self._zmq_sub_socket)
|
self._zmq_sub_stream = ZMQStream(self._zmq_sub_socket)
|
||||||
@ -35,10 +33,9 @@ class ServerDownlinkConnector(ZMQConnectorBase):
|
|||||||
self._zmq_sub_stream.close()
|
self._zmq_sub_stream.close()
|
||||||
|
|
||||||
|
|
||||||
class ServerUplinkConnector(ZMQConnectorBase):
|
class ServerUplinkConnector():
|
||||||
def __init__(self, zmq_context=None):
|
def __init__(self):
|
||||||
super(ServerUplinkConnector, self).__init__(zmq_context)
|
self._zmq_push_socket = zmq.Context.instance().socket(zmq.PUSH)
|
||||||
self._zmq_push_socket = self._zmq_context.socket(zmq.PUSH)
|
|
||||||
self._zmq_push_socket.connect(f'tcp://localhost:{TFWENV.RECEIVER_PORT}')
|
self._zmq_push_socket.connect(f'tcp://localhost:{TFWENV.RECEIVER_PORT}')
|
||||||
self._zmq_push_socket.setsockopt(zmq.SNDHWM, 0)
|
self._zmq_push_socket.setsockopt(zmq.SNDHWM, 0)
|
||||||
|
|
||||||
@ -51,6 +48,10 @@ class ServerUplinkConnector(ZMQConnectorBase):
|
|||||||
|
|
||||||
|
|
||||||
class ServerConnector(ServerUplinkConnector, ServerDownlinkConnector):
|
class ServerConnector(ServerUplinkConnector, ServerDownlinkConnector):
|
||||||
|
def __init__(self):
|
||||||
|
ServerUplinkConnector.__init__(self)
|
||||||
|
ServerDownlinkConnector.__init__(self)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
ServerUplinkConnector.close(self)
|
ServerUplinkConnector.close(self)
|
||||||
ServerDownlinkConnector.close(self)
|
ServerDownlinkConnector.close(self)
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
||||||
# All Rights Reserved. See LICENSE file for details.
|
|
||||||
|
|
||||||
import zmq
|
|
||||||
|
|
||||||
|
|
||||||
class ZMQConnectorBase:
|
|
||||||
def __init__(self, zmq_context=None):
|
|
||||||
self._zmq_context = zmq_context or zmq.Context.instance()
|
|
Loading…
Reference in New Issue
Block a user