From 723b0786cb245b9ba9c82daa764f77d2d6f37218 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 6 Jan 2023 17:15:31 +0100 Subject: [PATCH] ship_processor.go: make queueMessage() accept an redis.ChannelInterface instead of redis.Key so we can call redisNs.NewKey() as late as possible. --- ship_processor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ship_processor.go b/ship_processor.go index 08ce9af..ddb5a3d 100644 --- a/ship_processor.go +++ b/ship_processor.go @@ -21,7 +21,8 @@ func encodeMessage(v interface{}) ([]byte, bool) { return payload, true } -func queueMessage(key redis.Key, payload []byte) bool { +func queueMessage(channel redis.ChannelInterface, payload []byte) bool { + key := redisNs.NewKey(channel) err := redis.RegisterPublish(key.String(), payload).Err() if err != nil { log.WithError(err).Errorf("Failed to post to channel '%s'", key) @@ -32,7 +33,6 @@ func queueMessage(key redis.Key, payload []byte) bool { func encodeQueue(channel redis.Channel, v interface{}) bool { if payload, ok := encodeMessage(v); ok { - channel := redisNs.NewKey(channel) if queueMessage(channel, payload) { return true } @@ -102,7 +102,7 @@ func processTraces(traces []*ship.TransactionTraceV0) { } for _, channel := range channels { - queueMessage(redisNs.NewKey(channel), payload) + queueMessage(channel, payload) } } }