33 lines
605 B
Go
33 lines
605 B
Go
package rules
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"text/template"
|
|
|
|
"iwarma.ru/console/correlator/events"
|
|
)
|
|
|
|
type Action interface {
|
|
// Perform action for provided events
|
|
Perform(events *[]*events.Event) error
|
|
|
|
// ParseInterface Used for parsing from json
|
|
ParseInterface(v interface{}) error
|
|
|
|
// GetType Get type of action
|
|
GetType() string
|
|
|
|
json.Unmarshaler
|
|
json.Marshaler
|
|
}
|
|
|
|
func renderTemplate(templateSrc *template.Template, event *events.Event) (string, error) {
|
|
var buf bytes.Buffer
|
|
err := templateSrc.Execute(&buf, event)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return buf.String(), nil
|
|
}
|