From bb2f70925919097946c5fb2f4d4bebe55119e7cb Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Sun, 31 Jul 2022 15:12:31 -0400 Subject: [PATCH] fix batches --- internal/cmd/scheduler.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index bc205d1..e992e2a 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -377,11 +377,11 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli } defer rows.Close() - var ids []int64 + var ids []string for rows.Next() { var id int64 _ = rows.Scan(&id) - ids = append(ids, id) + ids = append(ids, fmt.Sprintf("%d", id)) } enqueued := 0 @@ -411,7 +411,7 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli logger.Debug("enqueueing batch", zap.Int("len", len(batch))) - unlocked, err := redisConn.EvalSha(ctx, luaSha, []string{"locks:accounts"}, batch).Int64Slice() + unlocked, err := redisConn.EvalSha(ctx, luaSha, []string{"locks:accounts"}, batch).StringSlice() if err != nil { logger.Error("failed to check for locked accounts", zap.Error(err)) } @@ -423,12 +423,7 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli return } - payloads := make([]string, len(unlocked)) - for i, id := range unlocked { - payloads[i] = fmt.Sprintf("%d", id) - } - - if err = queue.Publish(payloads...); err != nil { + if err = queue.Publish(unlocked...); err != nil { logger.Error("failed to enqueue account batch", zap.Error(err)) } }(i)