优化
This commit is contained in:
@@ -55,7 +55,7 @@ func (s *TaskScheduler) Start(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
// GVA reports the number of rows read from the database, not only
|
||||
// Report the number of rows read from the database, not only
|
||||
// the enabled rows that were scheduled successfully.
|
||||
s.logger.InfoContext(ctx, "定时任务加载完成", "task_count", len(items))
|
||||
} else {
|
||||
@@ -222,6 +222,13 @@ func (s *TaskScheduler) Subscribe(userID uint) chan []byte {
|
||||
if s.subscribers[userID] == nil {
|
||||
s.subscribers[userID] = map[chan []byte]struct{}{}
|
||||
}
|
||||
if len(s.subscribers[userID]) >= 10 {
|
||||
for old := range s.subscribers[userID] {
|
||||
delete(s.subscribers[userID], old)
|
||||
close(old)
|
||||
break
|
||||
}
|
||||
}
|
||||
s.subscribers[userID][ch] = struct{}{}
|
||||
s.subMu.Unlock()
|
||||
return ch
|
||||
|
||||
Reference in New Issue
Block a user