Make poll() just return the message
The driver shouldn't be pulling the namespace and version from the message since that's RPC specific stuff. Also, it's not terribly useful for the driver to pass back a target object describing the exchange and topic the message was received on since that's implicit in the listener.
This commit is contained in:
parent
7c3697f77b
commit
93447e8381
|
@ -26,9 +26,7 @@ class Listener(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def poll(self):
|
||||
# returns (target, message)
|
||||
# target includes the (exchange, topic, namespace, version) which the
|
||||
# message was sent to
|
||||
# returns message
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
|
|
|
@ -30,9 +30,9 @@ class ExecutorBase(object):
|
|||
self.callback = callback
|
||||
|
||||
def _process_one_message(self):
|
||||
(target, message) = self.listener.poll()
|
||||
message = self.listener.poll()
|
||||
try:
|
||||
self.callback(target, message)
|
||||
self.callback(message)
|
||||
except Exception:
|
||||
_LOG.exception(_("Failed to process message... skipping it."))
|
||||
finally:
|
||||
|
|
|
@ -57,15 +57,15 @@ class RPCDispatcher(object):
|
|||
endpoint_version = endpoint.target.version or '1.0'
|
||||
return utils.version_is_compatible(endpoint_version, version)
|
||||
|
||||
def __call__(self, target, message):
|
||||
def __call__(self, message):
|
||||
method = message.get('method')
|
||||
args = message.get('args', {})
|
||||
|
||||
version = target.version or '1.0'
|
||||
namespace = message.get('namespace')
|
||||
version = message.get('version', '1.0')
|
||||
|
||||
found_compatible = False
|
||||
for endpoint in self.endpoints:
|
||||
if target.namespace != endpoint.target.namespace:
|
||||
if namespace != endpoint.target.namespace:
|
||||
continue
|
||||
|
||||
is_compatible = self._is_compatible(endpoint, version)
|
||||
|
|
Loading…
Reference in New Issue