Skip to content

Commit

Permalink
stream: use well known st2. prefix in event names
Browse files Browse the repository at this point in the history
Now that the exchange name prefix is configurable, we have
to undo the prefix to maintain a backwards compatible API.
Also, having the event names vary based on config would be
a very bad UX, so we don't want to go there anyway.
  • Loading branch information
cognifloyd committed Nov 10, 2024
1 parent 8942c33 commit 396db76
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion st2common/st2common/stream/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ def get_consumers(self, consumer, channel):
raise NotImplementedError("get_consumers() is not implemented")

def processor(self, model=None):
exchange_prefix = cfg.CONF.messaging.prefix

def process(body, message):
meta = message.delivery_info
event_name = "%s__%s" % (meta.get("exchange"), meta.get("routing_key"))
event_prefix = meta.get("exchange", "")
if exchange_prefix != "st2" and event_prefix.startswith(exchange_prefix):
# use well-known event names over configurable exchange names
event_prefix = event_prefix.replace(f"{exchange_prefix}.", "st2.", 1)
event_name = f"{event_prefix}__{meta.get('routing_key')}"

try:
if model:
Expand Down

0 comments on commit 396db76

Please sign in to comment.