optimize foot copyright snaps

This commit is contained in:
RockYang
2024-07-22 17:54:09 +08:00
parent 1541d74c84
commit 4910be3403
14 changed files with 266 additions and 69 deletions

View File

@@ -29,6 +29,7 @@ type Service struct {
notifyQueue *store.RedisQueue
db *gorm.DB
running bool
retryCount map[uint]int
}
func NewService(name string, taskQueue *store.RedisQueue, notifyQueue *store.RedisQueue, db *gorm.DB, cli Client) *Service {
@@ -39,6 +40,7 @@ func NewService(name string, taskQueue *store.RedisQueue, notifyQueue *store.Red
notifyQueue: notifyQueue,
Client: cli,
running: true,
retryCount: make(map[uint]int),
}
}
@@ -57,8 +59,13 @@ func (s *Service) Run() {
// 如果配置了多个中转平台的 API KEY
// U,V 操作必须和 Image 操作属于同一个平台,否则找不到关联任务,需重新放回任务列表
if task.ChannelId != "" && task.ChannelId != s.Name {
if s.retryCount[task.Id] > 5 {
s.db.Model(model.MidJourneyJob{Id: task.Id}).Delete(&model.MidJourneyJob{})
continue
}
logger.Debugf("handle other service task, name: %s, channel_id: %s, drop it.", s.Name, task.ChannelId)
s.taskQueue.RPush(task)
s.retryCount[task.Id]++
time.Sleep(time.Second)
continue
}