diff options
Diffstat (limited to 'internal/api/handlers.go')
-rw-r--r-- | internal/api/handlers.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go index 4c4b2ec..bdde394 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -174,14 +174,13 @@ func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) { status.metrics.ResponseTime = status.overallStatus.ResponseTime case <-tick1s.C: - fmt.Println("1 s tick") case <-tick10s.C: for i := range status.incidents { runChance(0.05, func() { status.incidents[i].Status = StatusOperational }) } - runChance(1.0, func() { + runChance(0.08, func() { severity := SeverityMinor runChance(0.3, func() { severity = SeverityMajor @@ -191,6 +190,13 @@ func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) { runChance(0.5, func() { serviceStatus = StatusDegraded }) + + affectedServicesCount := rand.Intn(2) + 1 + affectedServices := randomSelect(status.services, affectedServicesCount) + affectedServiceNames := []string{} + for _, s := range affectedServices { + affectedServiceNames = append(affectedServiceNames, s.Id) + } newIncident := incident{ Id: fmt.Sprintf("%d", incidentId), Title: allIncidentTitles[i], @@ -198,7 +204,7 @@ func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) { Status: serviceStatus, Severity: severity, StartTime: time.Now().UTC(), - AffectedServices: []string{}, + AffectedServices: affectedServiceNames, } status.incidents = append(status.incidents, newIncident) incidentId++ |