Get rid of implicit message topic prefix

Callers of simple_message_to_bus need to set and export MSGTOPIC_PREFIX
explicitly.

This decouples the fedora-messaging-utils and web-data-analysis roles.

Additionally, don't assume /bin/sh is /bin/bash.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2021-09-07 13:34:03 +02:00
parent 8e05661fc5
commit a3203d29d9
4 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,10 @@
#!/bin/sh
MSGTOPIC_PREFIX="${MSGTOPIC_PREFIX:-logging.stats}"
topic="${MSGTOPIC_PREFIX}.$1"
#!/bin/bash
# To set a common prefix for all messages, do `export MSGTOPIC_PREFIX=...` in callers.
if [ -n "$MSGTOPIC_PREFIX" -a "${MSGTOPIC_PREFIX%.}" = "$MSGTOPIC_PREFIX" ]; then
MSGTOPIC_PREFIX="${MSGTOPIC_PREFIX}."
fi
topic="${MSGTOPIC_PREFIX}$1"
shift
sent_at="$(TZ=UTC date -Iseconds)"
id="$(uuidgen -r)"

View file

@ -19,6 +19,7 @@
# along with Fedora Project Infrastructure Ansible Repository. If
# not, see <http://www.gnu.org/licenses/>.
export MSGTOPIC_PREFIX=logging.stats
RUN_ID="$(uuidgen -r)"
simple_message_to_bus combinehttplogs.start run_id="$RUN_ID"

View file

@ -25,6 +25,8 @@
# we are 5 days behind.
# We have dropped this down to 3 days on 2019-10-01
export MSGTOPIC_PREFIX=logging.stats
RUN_ID="$(uuidgen -r)"
simple_message_to_bus condense-mirrorlogs.start run_id="$RUN_ID"

View file

@ -1,5 +1,6 @@
#!/bin/bash
export MSGTOPIC_PREFIX=logging.stats
RUN_ID="$(uuidgen -r)"
simple_message_to_bus countme-update.start run_id="$RUN_ID"