feat: Remove unused imports across charging engine modules

- Remove unused IntoResponse/warn/error/ChargingError/validate_* imports from api
- Remove unused AsyncCommands/error/ChargingSession/ErrorContext imports from credit_management
- Remove unused ErrorContext/ChargingError imports from engine
- Remove unused ErrorContext import from rating_billing and prefix unused variables with underscore
- Remove unused ErrorContext import from rating_plans_repo
- Remove unused log_error/validate_amount/validate_im
This commit is contained in:
nutcas3
2026-04-25 01:06:30 +03:00
parent eb8e7bc48a
commit 9d3b8428bd
2 changed files with 25 additions and 8 deletions
+17 -2
View File
@@ -202,7 +202,13 @@ func (cs *ChaosService) GetActiveExperiments() []*Experiment {
experiments := make([]*Experiment, 0, len(cs.active))
for _, exp := range cs.active {
experiments = append(experiments, exp)
// Create a copy to avoid race conditions
copy := *exp
if exp.Finished != nil {
finished := *exp.Finished
copy.Finished = &finished
}
experiments = append(experiments, &copy)
}
return experiments
}
@@ -213,7 +219,16 @@ func (cs *ChaosService) GetExperimentStatus(id string) (*Experiment, bool) {
defer cs.mu.RUnlock()
exp, exists := cs.active[id]
return exp, exists
if !exists {
return nil, false
}
// Create a copy to avoid race conditions
copy := *exp
if exp.Finished != nil {
finished := *exp.Finished
copy.Finished = &finished
}
return &copy, true
}
// Middleware function to inject chaos into HTTP requests