Skip to content

Commit

Permalink
fix #922 avoid mixing up post_exchange with exchange in display
Browse files Browse the repository at this point in the history
  • Loading branch information
petersilva committed Feb 5, 2024
1 parent d2d5284 commit fb40460
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions sarracenia/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,37 @@ def __resolved_exchanges(self, c, cfg, o):
exl.append(x)
return exl

def __resolved_post_exchanges(self, c, cfg, o):
"""
Guess the name of an exchange. looking at either a direct setting,
or an existing queue state file, or lastly just guess based on conventions.
"""
exl = []
#if hasattr(o,'declared_exchanges'):
# exl.extend(o.declared_exchanges)

if hasattr(o, 'post_exchange'):
if type(o.post_exchange) == list:
exl.extend(o.post_exchange)
else:
exl.append(o.post_exchange)
return exl

x = 'xs_%s' % o.post_broker.url.username

if hasattr(o, 'post_exchangeSuffix'):
x += '_%s' % o.post_exchangeSuffix

if hasattr(o, 'post_exchangeSplit'):
l = []
for i in range(0, o.instances):
y = x + '%02d' % i
l.append(y)
return l
else:
exl.append(x)
return exl

def __guess_queueName(self, c, cfg, o):
"""
Guess the name of a queue. looking at either a direct setting,
Expand Down Expand Up @@ -832,17 +863,8 @@ def _resolve_brokers(self):
if hasattr(o, 'post_broker') and o.post_broker is not None and o.post_broker.url is not None:
host = self._init_broker_host(o.post_broker.url.netloc)

#o.broker = o.post_broker
if hasattr(o, 'post_exchange'):
o.exchange = o.post_exchange
if hasattr(o, 'post_exchangeSplit'):
o.exchangeSplit = o.post_exchangeSplit
if hasattr(o, 'post_exchangeSuffix'):
o.exchangeSuffix = o.post_exchangeSuffix

xl = self.__resolved_exchanges(c, cfg, o)

self.configs[c][cfg]['options'].resolved_exchanges = xl
self.configs[c][cfg]['options'].resolved_exchanges = \
self.__resolved_post_exchanges(c, cfg, o)

if hasattr(o, 'post_exchange'):
self.brokers[host]['exchange'] = o.post_exchange
Expand Down

0 comments on commit fb40460

Please sign in to comment.