예제 #1
0
 def __init__(self, conf):
     self.conf = conf
     self._lock = threading.Lock()
     self._requests = {}
     self._poller = zmq_async.get_poller()
     self._receive_response_versions = \
         zmq_version.get_method_versions(self, 'receive_response')
     self._executor = zmq_async.get_executor(self._run_loop)
     self._executor.execute()
예제 #2
0
 def __init__(self, conf):
     self.conf = conf
     self._lock = threading.Lock()
     self._requests = {}
     self._poller = zmq_async.get_poller()
     self._receive_response_versions = \
         zmq_version.get_method_versions(self, 'receive_response')
     self._executor = zmq_async.get_executor(self._run_loop)
     self._executor.execute()
예제 #3
0
 def __init__(self, conf, poller, server):
     self.reply_sender = zmq_senders.ReplySenderProxy(conf)
     self.sockets_manager = zmq_sockets_manager.SocketsManager(
         conf, server.matchmaker, zmq.DEALER)
     self.host = None
     super(DealerConsumer, self).__init__(conf, poller, server, zmq.DEALER)
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     self.connection_updater = ConsumerConnectionUpdater(
         conf, self.matchmaker, self.socket)
     LOG.info(_LI("[%s] Run DEALER consumer"), self.host)
예제 #4
0
 def __init__(self, conf, poller, server):
     self.reply_sender = zmq_senders.ReplySenderProxy(conf)
     self.sockets_manager = zmq_sockets_manager.SocketsManager(
         conf, server.matchmaker, zmq.DEALER)
     self.host = None
     super(DealerConsumer, self).__init__(conf, poller, server, zmq.DEALER)
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     self.connection_updater = ConsumerConnectionUpdater(
         conf, self.matchmaker, self.socket)
     LOG.info(_LI("[%s] Run DEALER consumer"), self.host)
예제 #5
0
 def __init__(self, conf, poller, server):
     super(SubConsumer, self).__init__(conf, poller, server)
     self.matchmaker = SubscriptionMatchmakerWrapper(conf,
                                                     server.matchmaker)
     self.target = server.target
     self.socket = zmq_socket.ZmqSocket(self.conf, self.context, zmq.SUB,
                                        immediate=False,
                                        identity=self._generate_identity())
     self.sockets.append(self.socket)
     self.host = self.socket.handle.identity
     self._subscribe_to_topic()
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     self.connection_updater = SubscriberConnectionUpdater(
         conf, self.matchmaker, self.socket)
     self.poller.register(self.socket, self.receive_request)
     LOG.info(_LI("[%s] Run SUB consumer"), self.host)
예제 #6
0
 def __init__(self, conf, poller, server):
     super(SubConsumer, self).__init__(conf, poller, server)
     self.matchmaker = SubscriptionMatchmakerWrapper(
         conf, server.matchmaker)
     self.target = server.target
     self.socket = zmq_socket.ZmqSocket(self.conf,
                                        self.context,
                                        zmq.SUB,
                                        immediate=False,
                                        identity=self._generate_identity())
     self.sockets.append(self.socket)
     self.host = self.socket.handle.identity
     self._subscribe_to_topic()
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     self.connection_updater = SubscriberConnectionUpdater(
         conf, self.matchmaker, self.socket)
     self.poller.register(self.socket, self.receive_request)
     LOG.info(_LI("[%s] Run SUB consumer"), self.host)
예제 #7
0
 def __init__(self, conf):
     self.conf = conf
     self._lock = threading.Lock()
     self._send_versions = zmq_version.get_method_versions(self, 'send')
예제 #8
0
 def __init__(self, conf, poller, server):
     self.reply_sender = zmq_senders.ReplySenderDirect(conf)
     super(RouterConsumer, self).__init__(conf, poller, server, zmq.ROUTER)
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     LOG.info(_LI("[%s] Run ROUTER consumer"), self.host)
예제 #9
0
from oslo_messaging._drivers.zmq_driver import zmq_version

LOG = logging.getLogger(__name__)

zmq = zmq_async.import_zmq()


@six.add_metaclass(abc.ABCMeta)
class SenderBase(object):
    """Base request/response sending interface."""

    def __init__(self, conf, async=False):
        self.conf = conf
        self.async = async
        self._lock = threading.Lock()
        self._send_versions = zmq_version.get_method_versions(self, 'send')

    def _get_send_version(self, version):
        send_version = self._send_versions.get(version)
        if send_version is None:
            raise zmq_version.UnsupportedMessageVersionError(version)
        return send_version

    @abc.abstractmethod
    def send(self, socket, message):
        """Send a message via a socket in a thread-safe manner."""


class RequestSenderBase(SenderBase):
    pass
예제 #10
0
 def __init__(self):
     self._send_message_versions = \
         zmq_version.get_method_versions(self, 'send_message')
예제 #11
0
 def test_get_public_method_versions(self):
     do_versions = zmq_version.get_method_versions(self.doer, 'do')
     self.assertEqual(['1.1', '2.2', '3.3'], sorted(do_versions.keys()))
예제 #12
0
 def __init__(self, conf, use_async=False):
     self.conf = conf
     self.use_async = use_async
     self._lock = threading.Lock()
     self._send_versions = zmq_version.get_method_versions(self, 'send')
예제 #13
0
 def __init__(self, conf, poller, server):
     self.reply_sender = zmq_senders.ReplySenderDirect(conf)
     super(RouterConsumer, self).__init__(conf, poller, server, zmq.ROUTER)
     self._receive_request_versions = \
         zmq_version.get_method_versions(self, 'receive_request')
     LOG.info(_LI("[%s] Run ROUTER consumer"), self.host)