Chore: Remove context.TODO (#43458)

* Remove context.TODO() from services

* Fix live test
This commit is contained in:
idafurjes
2021-12-28 10:26:18 +01:00
committed by GitHub
parent 56b3dc5445
commit 56c3875bb9
24 changed files with 81 additions and 77 deletions
@@ -42,9 +42,9 @@ func (c *RedisFrameCache) GetActiveChannels(orgID int64) (map[string]json.RawMes
return info, nil
}
func (c *RedisFrameCache) GetFrame(orgID int64, channel string) (json.RawMessage, bool, error) {
func (c *RedisFrameCache) GetFrame(ctx context.Context, orgID int64, channel string) (json.RawMessage, bool, error) {
key := getCacheKey(orgchannel.PrependOrgID(orgID, channel))
cmd := c.redisClient.HGetAll(context.TODO(), key)
cmd := c.redisClient.HGetAll(ctx, key)
result, err := cmd.Result()
if err != nil {
return nil, false, err
@@ -59,7 +59,7 @@ const (
frameCacheTTL = 7 * 24 * time.Hour
)
func (c *RedisFrameCache) Update(orgID int64, channel string, jsonFrame data.FrameJSONCache) (bool, error) {
func (c *RedisFrameCache) Update(ctx context.Context, orgID int64, channel string, jsonFrame data.FrameJSONCache) (bool, error) {
c.mu.Lock()
if _, ok := c.frames[orgID]; !ok {
c.frames[orgID] = map[string]data.FrameJSONCache{}
@@ -74,8 +74,6 @@ func (c *RedisFrameCache) Update(orgID int64, channel string, jsonFrame data.Fra
pipe := c.redisClient.TxPipeline()
defer func() { _ = pipe.Close() }()
ctx := context.TODO()
pipe.HGetAll(ctx, key)
pipe.HMSet(ctx, key, map[string]string{
"schema": stringSchema,