split actions/trigggers into seperate files

This commit is contained in:
2023-07-18 09:34:47 +02:00
parent a2ea3209f1
commit a457a313b7
7 changed files with 132 additions and 121 deletions

30
actions/timeout.go Normal file
View File

@@ -0,0 +1,30 @@
package actions
import (
"fmt"
"time"
"unknown.com/gokill/internal"
)
type TimeOut struct {
Duration time.Duration
ActionChan chan bool
}
func (t TimeOut) Execute() {
fmt.Printf("Waiting %d seconds\n", t.Duration/time.Second)
time.Sleep(t.Duration)
t.ActionChan <- true
}
func NewTimeOut(config internal.ActionConfig, c chan bool) (Action, error) {
opts := config.Options
duration, ok := opts["duration"]
if !ok {
return nil, internal.OptionMissingError{"duration"}
}
return TimeOut{time.Duration(duration.(float64)) * time.Second, c}, nil
}