Skip to content

Commit 5430b32

Browse files
committed
Use 'nil' instead of empty map in 'catcher' calls system. Improve code readability and reduce memory allocation overhead.
1 parent 555c538 commit 5430b32

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

soc-ai/configurations/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ func (c *GPTConfig) UpdateGPTConfigurations() {
4040

4141
for {
4242
if err := utils.ConnectionChecker(GPT_API_ENDPOINT); err != nil {
43-
catcher.Error("Failed to establish internet connection", err, map[string]any{})
43+
catcher.Error("Failed to establish internet connection", err, nil)
4444
}
4545

4646
tempModuleConfig, err := client.GetUTMConfig(enum.SOCAI)
4747
if err != nil && err.Error() != "" && err.Error() != " " {
48-
catcher.Error("Error while getting GPT configuration", err, map[string]any{})
48+
catcher.Error("Error while getting GPT configuration", err, nil)
4949
time.Sleep(TIME_FOR_GET_CONFIG * time.Second)
5050
continue
5151
}
5252
if tempModuleConfig == nil {
53-
catcher.Error("Got nil config from server", nil, map[string]any{})
53+
catcher.Error("Got nil config from server", nil, nil)
5454
time.Sleep(TIME_FOR_GET_CONFIG * time.Second)
5555
continue
5656
}

soc-ai/processor/alertProcessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (p *Processor) processAlertsInfo() {
2121

2222
correlation, err := elastic.FindRelatedAlerts(alertInfo)
2323
if err != nil {
24-
catcher.Error("error finding related alerts", err, map[string]any{})
24+
catcher.Error("error finding related alerts", err, nil)
2525
}
2626

2727
details := schema.ConvertFromAlertToAlertDB(alertInfo)

soc-ai/processor/elastic.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p *Processor) processAlertToElastic() {
3030
if gptConfig.ChangeAlertStatus {
3131
err = elastic.ChangeAlertStatus(alert.AlertID, configurations.API_ALERT_COMPLETED_STATUS_CODE, alert.GPTClassification+" - "+alert.GPTReasoning)
3232
if err != nil {
33-
catcher.Error("error while changing alert status in elastic", err, map[string]any{})
33+
catcher.Error("error while changing alert status in elastic", err, nil)
3434
continue
3535
}
3636
catcher.Info("alert status changed to COMPLETED in Panel", map[string]any{"alert": alert.AlertID})
@@ -39,7 +39,7 @@ func (p *Processor) processAlertToElastic() {
3939
if gptConfig.AutomaticIncidentCreation && alert.GPTClassification == "possible incident" {
4040
incidentsDetails, err := elastic.GetIncidentsByPattern("Incident in " + alert.DataSource)
4141
if err != nil {
42-
catcher.Error("error while getting incidents by pattern", err, map[string]any{})
42+
catcher.Error("error while getting incidents by pattern", err, nil)
4343
continue
4444
}
4545

@@ -50,7 +50,7 @@ func (p *Processor) processAlertToElastic() {
5050
incidentExists = true
5151
err = elastic.AddAlertToIncident(incident.ID, alert)
5252
if err != nil {
53-
catcher.Error("error while adding alert to incident", err, map[string]any{})
53+
catcher.Error("error while adding alert to incident", err, nil)
5454
continue
5555
}
5656
}
@@ -60,7 +60,7 @@ func (p *Processor) processAlertToElastic() {
6060
if !incidentExists {
6161
err = elastic.CreateNewIncident(alert)
6262
if err != nil {
63-
catcher.Error("error while creating incident", err, map[string]any{})
63+
catcher.Error("error while creating incident", err, nil)
6464
continue
6565
}
6666
}

soc-ai/processor/listener.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func (p *Processor) handleAlerts(c *gin.Context) {
4242
}
4343

4444
if !configurations.GetGPTConfig().ModuleActive {
45-
catcher.Error("Droping request to /process, GPT module is not active", nil, map[string]any{})
45+
catcher.Error("Droping request to /process, GPT module is not active", nil, nil)
4646
c.JSON(http.StatusOK, "GPT module is not active")
4747
return
4848
}
4949

5050
var ids []string
5151
if err := c.BindJSON(&ids); err != nil {
52-
catcher.Error("error binding JSON", err, map[string]any{})
52+
catcher.Error("error binding JSON", err, nil)
5353
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
5454
return
5555
}
@@ -69,22 +69,22 @@ func (p *Processor) handleAlerts(c *gin.Context) {
6969
var gptResponses []schema.GPTAlertResponse
7070
err = json.Unmarshal(result, &gptResponses)
7171
if err != nil {
72-
catcher.Error("error decoding response from elastic", err, map[string]any{})
72+
catcher.Error("error decoding response from elastic", err, nil)
7373
c.JSON(http.StatusInternalServerError, fmt.Sprintf("error decoding response: %v", err))
7474
return
7575
}
7676

7777
if len(gptResponses) == 0 {
7878
err = elastic.IndexStatus(id, "Processing", "create")
7979
if err != nil {
80-
catcher.Error("error creating doc in index", err, map[string]any{})
80+
catcher.Error("error creating doc in index", err, nil)
8181
c.JSON(http.StatusInternalServerError, fmt.Sprintf("error creating doc in index: %v", err))
8282
return
8383
}
8484
} else {
8585
err = elastic.IndexStatus(id, "Processing", "update")
8686
if err != nil {
87-
catcher.Error("error updating doc in index", err, map[string]any{})
87+
catcher.Error("error updating doc in index", err, nil)
8888
c.JSON(http.StatusInternalServerError, fmt.Sprintf("error updating doc in index: %v", err))
8989
return
9090
}

soc-ai/processor/processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (p *Processor) ProcessData() {
5555
func (p *Processor) RegisterError(message, id string) {
5656
err := elastic.IndexStatus(id, "Error", "update")
5757
if err != nil {
58-
catcher.Error("error while indexing error in elastic", err, map[string]any{})
58+
catcher.Error("error while indexing error in elastic", err, nil)
5959
}
60-
catcher.Error(message, nil, map[string]any{})
60+
catcher.Error(message, nil, nil)
6161
}

0 commit comments

Comments
 (0)