fix: 代码修复
This commit is contained in:
@@ -149,8 +149,8 @@ func (s *KeyCronService) worker(ctx context.Context, wg *sync.WaitGroup, group *
|
||||
for key := range jobs {
|
||||
isValid, validationErr := s.Validator.ValidateSingleKey(ctx, &key, group)
|
||||
|
||||
newStatus := key.Status
|
||||
newErrorReason := key.ErrorReason
|
||||
var newStatus string
|
||||
var newErrorReason string
|
||||
statusChanged := false
|
||||
|
||||
if validationErr != nil {
|
||||
@@ -161,11 +161,8 @@ func (s *KeyCronService) worker(ctx context.Context, wg *sync.WaitGroup, group *
|
||||
// Validation succeeded
|
||||
if isValid {
|
||||
newStatus = "active"
|
||||
newErrorReason = "" // Clear reason on success
|
||||
newErrorReason = ""
|
||||
} else {
|
||||
// This case might happen if the key is valid but has no quota, etc.
|
||||
// The error would be in validationErr, so this branch is less likely.
|
||||
// We still mark it as inactive but without a specific error from our side.
|
||||
newStatus = "inactive"
|
||||
newErrorReason = "Validation returned false without a specific error."
|
||||
}
|
||||
|
@@ -57,12 +57,12 @@ func (s *KeyManualValidationService) StartValidationTask(group *models.Group) (*
|
||||
}
|
||||
|
||||
// Run the validation in a separate goroutine
|
||||
go s.runValidation(group, keys, taskStatus)
|
||||
go s.runValidation(group, keys)
|
||||
|
||||
return taskStatus, nil
|
||||
}
|
||||
|
||||
func (s *KeyManualValidationService) runValidation(group *models.Group, keys []models.APIKey, task *TaskStatus) {
|
||||
func (s *KeyManualValidationService) runValidation(group *models.Group, keys []models.APIKey) {
|
||||
logrus.Infof("Starting manual validation for group %s", group.Name)
|
||||
|
||||
jobs := make(chan models.APIKey, len(keys))
|
||||
@@ -70,7 +70,7 @@ func (s *KeyManualValidationService) runValidation(group *models.Group, keys []m
|
||||
|
||||
concurrency := s.SettingsManager.GetInt("key_validation_concurrency", 10)
|
||||
if concurrency <= 0 {
|
||||
concurrency = 10 // Fallback to a safe default
|
||||
concurrency = 10
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
Reference in New Issue
Block a user