The patch you've applied here will do what you want with minimal negative
implications.
Having said that, I think it's preferable to use subclasses to do this kind
of override. The following would achieve the same thing as your patch:
# app/dependencies.py
from nameko.rpc import ReplyListener as NamekoReplyListener
from nameko.rpc import RpcProxy as NamekoRpcProxy
# override to create a non-durable queue
class ReplyListener(NamekoReplyListener):
def setup(self):
service_uuid = uuid.uuid4()
service_name = self.container.service_name
queue_name = RPC_REPLY_QUEUE_TEMPLATE.format(
service_name, service_uuid)
self.routing_key = str(service_uuid)
exchange = get_rpc_exchange(self.container.config)
self.queue = Queue(
queue_name,
exchange=exchange,
routing_key=self.routing_key,
auto_delete=True,
exclusive=True,
durable=False # the override
)
self.queue_consumer.register_provider(self)
# override to use custom ReplyListener
class RpcProxy(NamekoRpcProxy):
rpc_reply_listener = ReplyListener()
#app/service.py
from app.dependencies import RpcProxy
class Service:
name = "nondurable"
rpc_proxy = RpcProxy() # your subclass
...
Although this is our preferred pattern we aren't great at making it easy to
do. This situation would be much better if we exposed "durable"` or
"queue_params" as an attribute of the ReplyListener class. Then you could
do simply:
# app/dependencies.py
from nameko.rpc import ReplyListener as NamekoReplyListener
from nameko.rpc import RpcProxy as NamekoRpcProxy
# override to specify a non-durable queue
class ReplyListener(NamekoReplyListener):
queue_params = {
'durable': False
}
# override to use custom ReplyListener
class RpcProxy(NamekoRpcProxy):
rpc_reply_listener = ReplyListener()
I have started to introduce this pattern as part of a recent PR (see
https://github.com/onefinestay/nameko/pull/337/files#diff-f6430d9814b008d760592d1baedbed66R379\)
···
On Friday, October 21, 2016 at 2:19:12 PM UTC+1, tsachi...@gmail.com wrote:
Any help?