mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
make sure we get all of it
This commit is contained in:
parent
3c88ab2041
commit
6d0140151b
1 changed files with 8 additions and 3 deletions
|
@ -3,6 +3,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -484,10 +485,14 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
|
||||||
}
|
}
|
||||||
|
|
||||||
chunks := [][]string{}
|
chunks := [][]string{}
|
||||||
|
chunkSize := int(math.Ceil(float64(len(ids)) / float64(accountEnqueueSeconds)))
|
||||||
for i := 0; i < accountEnqueueSeconds; i++ {
|
for i := 0; i < accountEnqueueSeconds; i++ {
|
||||||
min := (i * len(ids) / accountEnqueueSeconds)
|
left := i * chunkSize
|
||||||
max := ((i + 1) * len(ids)) / accountEnqueueSeconds
|
right := (i + 1) * chunkSize
|
||||||
chunks = append(chunks, ids[min:max])
|
if right > len(ids) {
|
||||||
|
right = len(ids)
|
||||||
|
}
|
||||||
|
chunks = append(chunks, ids[left:right])
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = statsd.Histogram("apollo.queue.runtime", float64(time.Since(now).Milliseconds()), []string{"queue:notifications"}, 1)
|
_ = statsd.Histogram("apollo.queue.runtime", float64(time.Since(now).Milliseconds()), []string{"queue:notifications"}, 1)
|
||||||
|
|
Loading…
Reference in a new issue