Skip to content

Commit e10aae6

Browse files
committedMay 1, 2024··
Remove delay option
Signed-off-by: Christian König <[email protected]>
1 parent d5bb89d commit e10aae6

File tree

6 files changed

+4
-28
lines changed

6 files changed

+4
-28
lines changed
 

‎Readme.md

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ Currently the following options can be set via `config.yml`
6969
```yaml
7070
---
7171
options:
72-
delay: 500ms
7372
filter_strings: ["type=container"]
7473
exclude_strings: ["Action=exec_start", "Action=exec_die", "Action=exec_create"]
7574
log_level: debug

‎src/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
options:
3-
delay: 500ms
43
filter_strings: ["type=container"]
54
exclude_strings: ["Action=exec_start", "Action=exec_die", "Action=exec_create"]
65
log_level: debug

‎src/events.go

-11
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ func processEvent(event events.Message) {
1818
var msg_builder, title_builder strings.Builder
1919
var ActorID, ActorImage, ActorName, TitleID, ActorImageVersion string
2020

21-
// Adding a small configurable delay here
22-
// Sometimes events are pushed through the event channel really quickly, but they arrive on the notification clients in
23-
// wrong order (probably due to message delivery time), e.g. Pushover is susceptible for this.
24-
// Finishing this function not before a certain time before draining the next event from the event channel in main() solves the issue
25-
timer := time.NewTimer(config.Options.Delay)
26-
2721
ActorID = getActorID(event)
2822
ActorImage = getActorImage(event)
2923
ActorName = getActorName(event)
@@ -88,11 +82,6 @@ func processEvent(event events.Message) {
8882
// function will finish when all reporters finished
8983
sendNotifications(timestamp, message, title, config.Reporters)
9084

91-
// block function until time (delay) triggers
92-
// if sendNotifications is faster than the delay, function blocks here until delay is over
93-
// if sendNotifications takes longer than the delay, trigger already fired and no delay is added
94-
<-timer.C
95-
9685
}
9786

9887
func getActorID(event events.Message) string {

‎src/notifications.go

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type ReporterError struct {
2222
func sendNotifications(timestamp time.Time, message string, title string, reporters []string) {
2323
// Sending messages to different services as goroutines concurrently
2424
// Adding a wait group here to delay execution until all functions return,
25-
// otherwise delaying in processEvent() would not make any sense
2625

2726
var wg sync.WaitGroup
2827
var ReporterErrors []ReporterError

‎src/startup.go

-7
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ func buildStartupMessage(timestamp time.Time) string {
4444
startup_message_builder.WriteString("\nMattermost notification disabled")
4545
}
4646

47-
if config.Options.Delay > 0 {
48-
startup_message_builder.WriteString("\nUsing delay of " + config.Options.Delay.String())
49-
} else {
50-
startup_message_builder.WriteString("\nDelay disabled")
51-
}
52-
5347
startup_message_builder.WriteString("\nLog level: " + config.Options.LogLevel)
5448

5549
if config.Options.ServerTag != "" {
@@ -102,7 +96,6 @@ func logArguments() {
10296
Str("MattermostUser", config.Reporter.Mattermost.User),
10397
),
10498
).
105-
Str("Delay", config.Options.Delay.String()).
10699
Str("Loglevel", config.Options.LogLevel).
107100
Str("ServerTag", config.Options.ServerTag).
108101
Str("Filter", strings.Join(config.Options.FilterStrings, " ")).

‎src/types.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package main
22

3-
import "time"
4-
53
type pushover struct {
64
Enabled bool
75
APIToken string `yaml:"api_token"`
@@ -36,11 +34,10 @@ type reporter struct {
3634
}
3735

3836
type options struct {
39-
FilterStrings []string `yaml:"filter_strings,flow"`
40-
ExcludeStrings []string `yaml:"exclude_strings,flow"`
41-
LogLevel string `yaml:"log_level"`
42-
ServerTag string `yaml:"server_tag"`
43-
Delay time.Duration `yaml:"delay"`
37+
FilterStrings []string `yaml:"filter_strings,flow"`
38+
ExcludeStrings []string `yaml:"exclude_strings,flow"`
39+
LogLevel string `yaml:"log_level"`
40+
ServerTag string `yaml:"server_tag"`
4441
}
4542

4643
type Config struct {

0 commit comments

Comments
 (0)
Please sign in to comment.