Commit 3fb16bbc authored by vicotor's avatar vicotor

update for syncer

parent 2c242dfa
...@@ -159,7 +159,7 @@ func GetTasks() ([]TaskJob, error) { ...@@ -159,7 +159,7 @@ func GetTasks() ([]TaskJob, error) {
Ascending: false, Ascending: false,
// NullsFirst bool // NullsFirst bool
// ForeignTable string // ForeignTable string
}).Range(0, 10, "").Execute() }).Range(0, 100, "").Execute()
if err != nil { if err != nil {
slog.Error("select * from followers error", err) slog.Error("select * from followers error", err)
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"code.wuban.net.cn/odysseus/twitter_syncer/swarm" "code.wuban.net.cn/odysseus/twitter_syncer/swarm"
"fmt" "fmt"
"log/slog" "log/slog"
"math/rand"
"sync" "sync"
"time" "time"
) )
...@@ -82,10 +83,12 @@ func (w *Work) RunJob(t TaskJob) chan<- interface{} { ...@@ -82,10 +83,12 @@ func (w *Work) RunJob(t TaskJob) chan<- interface{} {
if t.TaskType == FollowType { if t.TaskType == FollowType {
cli := swarm.GetSwarm() cli := swarm.GetSwarm()
randomIdx := rand.Intn(10) + 1
randomDelay := time.Duration(randomIdx) * time.Second
secondTicker := time.NewTicker(time.Second * 20) secondTicker := time.NewTicker(time.Second*20 + randomDelay)
fiveMinutesTicker := time.NewTicker(time.Minute * 1) fiveMinutesTicker := time.NewTicker(time.Minute*1 + randomDelay)
halfHourTicker := time.NewTicker(time.Minute * 30) halfHourTicker := time.NewTicker(time.Minute*30 + randomDelay)
first := true first := true
recordFc := make([]TimeAndFollowCount, 0, 100) recordFc := make([]TimeAndFollowCount, 0, 100)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment