From 3fa1804c1aee0fa12772413e7382813e8df28370 Mon Sep 17 00:00:00 2001 From: gipsh Date: Tue, 22 Aug 2023 15:24:14 -0300 Subject: [PATCH] add redis prefix to communication channel (#651) --- common/client/cache/notional/cache.go | 9 ++++++++- jobs/jobs/notional/notional.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/client/cache/notional/cache.go b/common/client/cache/notional/cache.go index 4ac94508..4691e9f8 100644 --- a/common/client/cache/notional/cache.go +++ b/common/client/cache/notional/cache.go @@ -65,7 +65,7 @@ func NewNotionalCache(ctx context.Context, redisClient *redis.Client, prefix str return &NotionalCache{ client: redisClient, pubSub: pubsub, - channel: channel, + channel: formatChannel(prefix, channel), notionalMap: sync.Map{}, prefix: prefix, logger: log}, nil @@ -180,3 +180,10 @@ func (c *NotionalCache) renderKey(key string) string { func (c *NotionalCache) renderRegExp() string { return "*" + c.renderKey(wormscanNotionalCacheKeyRegex) } + +func formatChannel(prefix string, channel string) string { + if prefix != "" { + return fmt.Sprintf("%s:%s", prefix, channel) + } + return channel +} diff --git a/jobs/jobs/notional/notional.go b/jobs/jobs/notional/notional.go index cc97a163..e9686113 100644 --- a/jobs/jobs/notional/notional.go +++ b/jobs/jobs/notional/notional.go @@ -28,7 +28,7 @@ func NewNotionalJob(api *coingecko.CoingeckoAPI, cacheClient *redis.Client, cach coingeckoAPI: api, cacheClient: cacheClient, cachePrefix: cachePrefix, - cacheChannel: cacheChannel, + cacheChannel: formatChannel(cachePrefix, cacheChannel), p2pNetwork: p2pNetwork, logger: logger, }