mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-14 16:07:42 +00:00
Revert "optimize scheduler to reduce memory allocations"
This reverts commit f41dd925e4
.
This commit is contained in:
parent
f41dd925e4
commit
b1ed5fb71a
1 changed files with 9 additions and 19 deletions
|
@ -21,7 +21,7 @@ import (
|
||||||
"github.com/christianselig/apollo-backend/internal/repository"
|
"github.com/christianselig/apollo-backend/internal/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
const batchSize = 1000
|
const batchSize = 250
|
||||||
|
|
||||||
func SchedulerCmd(ctx context.Context) *cobra.Command {
|
func SchedulerCmd(ctx context.Context) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
@ -203,7 +203,7 @@ func enqueueUsers(ctx context.Context, logger *zap.Logger, statsd *statsd.Client
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
next := now.Add(domain.NotificationCheckInterval)
|
next := now.Add(domain.NotificationCheckInterval)
|
||||||
|
|
||||||
var ids []int64
|
ids := []int64{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
tags := []string{"queue:users"}
|
tags := []string{"queue:users"}
|
||||||
|
@ -229,16 +229,11 @@ func enqueueUsers(ctx context.Context, logger *zap.Logger, statsd *statsd.Client
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
affected := rows.CommandTag().RowsAffected()
|
|
||||||
ids = make([]int64, affected)
|
|
||||||
|
|
||||||
var id int64
|
var id int64
|
||||||
for i := 0; rows.Next(); i++ {
|
|
||||||
_ = rows.Scan(&id)
|
_ = rows.Scan(&id)
|
||||||
ids[i] = id
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -388,7 +383,7 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
next := now.Add(domain.NotificationCheckInterval)
|
next := now.Add(domain.NotificationCheckInterval)
|
||||||
|
|
||||||
var ids []int64
|
ids := []int64{}
|
||||||
enqueued := 0
|
enqueued := 0
|
||||||
skipped := 0
|
skipped := 0
|
||||||
|
|
||||||
|
@ -417,15 +412,10 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
affected := rows.CommandTag().RowsAffected()
|
|
||||||
ids = make([]int64, affected)
|
|
||||||
|
|
||||||
var id int64
|
var id int64
|
||||||
for i := 0; rows.Next(); i++ {
|
|
||||||
_ = rows.Scan(&id)
|
_ = rows.Scan(&id)
|
||||||
ids[i] = id
|
ids = append(ids, id)
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue