feat preload pushers
Some checks failed
Build image / build (push) Failing after 5m4s

This commit is contained in:
timerzz 2024-05-21 23:21:20 +08:00
parent d4cd0bd2d1
commit 1cfe78538d
2 changed files with 5 additions and 3 deletions

View File

@ -40,8 +40,10 @@ func (c *CoachOutlet) SetOption(cfg model.WatchInfo) {
}
func (c *CoachOutlet) Cancel() {
if c.cancel != nil {
c.cancel()
}
}
func (c *CoachOutlet) Restart() {
c.Cancel()

View File

@ -127,7 +127,7 @@ func (c *Controller) List(req ListWatcherInfoRequest) (resp web.ListResponse[mod
}
offset := (req.Page - 1) * req.Size
if err = tx.Order("created_at desc").Limit(req.Size).Offset(offset).
if err = tx.Order("created_at desc").Limit(req.Size).Offset(offset).Preload("Pushers").
Find(&resp.List).Error; err != nil {
return resp, fmt.Errorf("查询列表失败:%v", err)
}
@ -146,7 +146,7 @@ func (c *Controller) Delete(uid string) error {
func (c *Controller) Stop(uid string) error {
c.lock.RLock()
if watcher, ok := c.m[uid]; ok {
if watcher, ok := c.m[uid]; ok && watcher != nil {
watcher.Cancel()
}
c.lock.RUnlock()