This commit is contained in:
@@ -69,6 +69,9 @@ func (s *ConcurrencyService) List(ctx context.Context) ([]*ConcurrencyStatus, er
|
||||
if err != nil && err != redis.Nil {
|
||||
current = 0
|
||||
}
|
||||
if current < 0 {
|
||||
current = 0
|
||||
}
|
||||
|
||||
status.Current = current
|
||||
status.Available = int64(cfg.MaxConcurrency) - current
|
||||
@@ -104,6 +107,9 @@ func (s *ConcurrencyService) GetByTaskType(ctx context.Context, taskType string)
|
||||
if err != nil && err != redis.Nil {
|
||||
current = 0
|
||||
}
|
||||
if current < 0 {
|
||||
current = 0
|
||||
}
|
||||
|
||||
status.Current = current
|
||||
status.Available = int64(cfg.MaxConcurrency) - current
|
||||
@@ -120,8 +126,8 @@ func (s *ConcurrencyService) GetByTaskType(ctx context.Context, taskType string)
|
||||
// UpdateMaxConcurrency 更新最大并发数
|
||||
func (s *ConcurrencyService) UpdateMaxConcurrency(ctx context.Context, taskType string, maxConcurrency int, updatedBy uint) error {
|
||||
// 验证参数
|
||||
if maxConcurrency < 1 || maxConcurrency > 1000 {
|
||||
return errors.New(errors.CodeInvalidParam, "并发数必须在 1-1000 之间")
|
||||
if maxConcurrency < 1 {
|
||||
return errors.New(errors.CodeInvalidParam, "并发数必须为正整数")
|
||||
}
|
||||
|
||||
// 验证任务类型存在
|
||||
@@ -248,6 +254,7 @@ func (s *ConcurrencyService) InitFromDB(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
}
|
||||
_ = s.redis.Del(ctx, constants.RedisPollingConcurrencyConfigKey("stop_start")).Err()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -269,12 +276,16 @@ func pollingConcurrencyCurrentKey(taskType string) string {
|
||||
// getTaskTypeName 获取任务类型的中文名称
|
||||
func (s *ConcurrencyService) getTaskTypeName(taskType string) string {
|
||||
switch taskType {
|
||||
case constants.TaskTypePollingRealname:
|
||||
case "realname":
|
||||
return "实名检查"
|
||||
case constants.TaskTypePollingCarddata:
|
||||
case "carddata":
|
||||
return "流量检查"
|
||||
case constants.TaskTypePollingPackage:
|
||||
case "package":
|
||||
return "套餐检查"
|
||||
case "protect":
|
||||
return "保护期检查"
|
||||
case "card_status":
|
||||
return "卡状态检查"
|
||||
default:
|
||||
return taskType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user