Skip to content

Commit

Permalink
refactor publish to use tee
Browse files Browse the repository at this point in the history
  • Loading branch information
cgsdev0 committed Aug 24, 2023
1 parent 05123e8 commit 7151f8c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ function publish() {
local line
TOPIC="$1"
if [[ -z "$TOPIC" ]]; then
debug "ATTEMPTED TO PUBLISH ON EMPTY TOPIC"
return
fi
if [[ ! -d "pubsub/${TOPIC}" ]]; then
debug "NO SUBSCRIBERS ON ${TOPIC}"
return
fi
while IFS= read -r line; do
find pubsub/"${TOPIC}" -type p \
| xargs -P 4 -I {} bash -c "printf '%s\n' '$line' > {}"
done
TEE_ARGS=$(find pubsub/"${TOPIC}" -type p)
if [[ -z "$TEE_ARGS" ]]; then
return
fi
tee $TEE_ARGS > /dev/null
}

event() {
Expand Down

0 comments on commit 7151f8c

Please sign in to comment.