@ -17,6 +17,7 @@ import logging
import oslo_messaging . _drivers . zmq_driver . broker . zmq_base_proxy as base_proxy
from oslo_messaging . _drivers . zmq_driver . broker import zmq_call_proxy
from oslo_messaging . _drivers . zmq_driver . broker import zmq_fanout_proxy
from oslo_messaging . _drivers . zmq_driver import zmq_async
from oslo_messaging . _drivers . zmq_driver import zmq_serializer
from oslo_messaging . _i18n import _LI
@ -27,27 +28,34 @@ class UniversalProxy(base_proxy.BaseProxy):
def __init__ ( self , conf , context ) :
super ( UniversalProxy , self ) . __init__ ( conf , context )
self . tcp_frontend = zmq_call_proxy . FrontendTcpRouter ( conf , context )
self . backend_matcher = BackendMatcher ( conf , context )
self . poller = zmq_async . get_poller (
native_zmq = conf . rpc_zmq_native )
self . tcp_frontend = zmq_call_proxy . FrontendTcpRouter (
conf , context , poller = self . poller )
self . backend_matcher = BackendMatcher (
conf , context , poller = self . poller )
call = zmq_serializer . CALL_TYPE
self . call_backend = self . backend_matcher . backends [ call ]
LOG . info ( _LI ( " Starting universal-proxy thread " ) )
def run ( self ) :
message = self . tcp_frontend . receive_incoming ( )
if message is not None :
self . backend_matcher . redirect_to_backend ( message )
message , socket = self . poller . poll ( self . conf . rpc_poll_timeout )
if message is None :
return
LOG . info ( _LI ( " Received message at universal proxy: %s " ) % str ( message ) )
reply , socket = self . call_backend . receive_outgoing_reply ( )
if reply is not None :
self . tcp_frontend . redirect_outgoing_reply ( reply )
if socket == self . tcp_frontend . frontend :
self . backend_matcher . redirect_to_backend ( message )
else :
self . tcp_frontend . redirect_outgoing_reply ( message )
class BackendMatcher ( base_proxy . BaseBackendMatcher ) :
def __init__ ( self , conf , context ):
super ( BackendMatcher , self ) . __init__ ( conf , None , context )
direct_backend = zmq_call_proxy . DealerBackend ( conf , context )
def __init__ ( self , conf , context , poller = None ):
super ( BackendMatcher , self ) . __init__ ( conf , poller , context )
direct_backend = zmq_call_proxy . DealerBackend ( conf , context , poller )
self . backends [ zmq_serializer . CALL_TYPE ] = direct_backend
self . backends [ zmq_serializer . CAST_TYPE ] = direct_backend
fanout_backend = zmq_fanout_proxy . PublisherBackend ( conf , context )