add redis prefix to communication channel (#651)
This commit is contained in:
parent
0741ef7045
commit
3fa1804c1a
|
@ -65,7 +65,7 @@ func NewNotionalCache(ctx context.Context, redisClient *redis.Client, prefix str
|
||||||
return &NotionalCache{
|
return &NotionalCache{
|
||||||
client: redisClient,
|
client: redisClient,
|
||||||
pubSub: pubsub,
|
pubSub: pubsub,
|
||||||
channel: channel,
|
channel: formatChannel(prefix, channel),
|
||||||
notionalMap: sync.Map{},
|
notionalMap: sync.Map{},
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
logger: log}, nil
|
logger: log}, nil
|
||||||
|
@ -180,3 +180,10 @@ func (c *NotionalCache) renderKey(key string) string {
|
||||||
func (c *NotionalCache) renderRegExp() string {
|
func (c *NotionalCache) renderRegExp() string {
|
||||||
return "*" + c.renderKey(wormscanNotionalCacheKeyRegex)
|
return "*" + c.renderKey(wormscanNotionalCacheKeyRegex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatChannel(prefix string, channel string) string {
|
||||||
|
if prefix != "" {
|
||||||
|
return fmt.Sprintf("%s:%s", prefix, channel)
|
||||||
|
}
|
||||||
|
return channel
|
||||||
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func NewNotionalJob(api *coingecko.CoingeckoAPI, cacheClient *redis.Client, cach
|
||||||
coingeckoAPI: api,
|
coingeckoAPI: api,
|
||||||
cacheClient: cacheClient,
|
cacheClient: cacheClient,
|
||||||
cachePrefix: cachePrefix,
|
cachePrefix: cachePrefix,
|
||||||
cacheChannel: cacheChannel,
|
cacheChannel: formatChannel(cachePrefix, cacheChannel),
|
||||||
p2pNetwork: p2pNetwork,
|
p2pNetwork: p2pNetwork,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue