From f375e7a85a9c74a6b77438139bee4750c2aa00d4 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Fri, 8 Aug 2025 13:48:29 -0400 Subject: Random affected services Incidents are not every 10 seconds --- internal/api/handlers.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'internal/api/handlers.go') 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++ -- cgit