get string slice straight from command result

This commit is contained in:
Andre Medeiros 2022-07-13 16:24:46 -04:00
parent e1b880d063
commit 80bae7ff9f

View file

@ -454,25 +454,19 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
logger.Debug("enqueueing batch", zap.Int("len", len(batch))) logger.Debug("enqueueing batch", zap.Int("len", len(batch)))
res, err := redisConn.EvalSha(ctx, luaSha, []string{"locks:accounts"}, batch).Result() unlocked, err := redisConn.EvalSha(ctx, luaSha, []string{"locks:accounts"}, batch).StringSlice()
if err != nil { if err != nil {
logger.Error("failed to check for locked accounts", zap.Error(err)) logger.Error("failed to check for locked accounts", zap.Error(err))
} }
vals := res.([]interface{}) skipped += len(batch) - len(unlocked)
skipped += len(batch) - len(vals) enqueued += len(unlocked)
enqueued += len(vals)
if len(vals) == 0 { if len(unlocked) == 0 {
return return
} }
batchIds := make([]string, len(vals)) if err = queue.Publish(unlocked...); err != nil {
for k, v := range vals {
batchIds[k] = v.(string)
}
if err = queue.Publish(batchIds...); err != nil {
logger.Error("failed to enqueue account batch", zap.Error(err)) logger.Error("failed to enqueue account batch", zap.Error(err))
} }
}(i) }(i)