fixed issue with blocking alert channel send
This commit is contained in:
parent
5a90d141ab
commit
ebaeeaa1e5
|
@ -18,8 +18,8 @@ const (
|
||||||
|
|
||||||
type ComponentConfig struct {
|
type ComponentConfig struct {
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
RateMs *int `yaml:"rate-ms,omitempty"`
|
|
||||||
Position [][]int `yaml:"position,flow"`
|
Position [][]int `yaml:"position,flow"`
|
||||||
|
RateMs *int `yaml:"rate-ms,omitempty"`
|
||||||
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
|
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
|
||||||
Type ComponentType `yaml:",omitempty"`
|
Type ComponentType `yaml:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ type Command struct {
|
||||||
|
|
||||||
func NewConsumer() *Consumer {
|
func NewConsumer() *Consumer {
|
||||||
return &Consumer{
|
return &Consumer{
|
||||||
SampleChannel: make(chan *Sample),
|
SampleChannel: make(chan *Sample, 10),
|
||||||
AlertChannel: make(chan *Alert),
|
AlertChannel: make(chan *Alert, 10),
|
||||||
CommandChannel: make(chan *Command),
|
CommandChannel: make(chan *Command, 10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
data/item.go
14
data/item.go
|
@ -136,7 +136,7 @@ func (i *Item) executeInteractiveShellCmd(variables []string) (string, error) {
|
||||||
timeout := make(chan bool, 1)
|
timeout := make(chan bool, 1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Duration(i.RateMs))
|
time.Sleep(time.Duration(i.RateMs / 2))
|
||||||
timeout <- true
|
timeout <- true
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -165,9 +165,15 @@ func (i *Item) executeInteractiveShellCmd(variables []string) (string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Item) transformInteractiveShellCmd(value string) (string, error) {
|
func (i *Item) transformInteractiveShellCmd(sample string) (string, error) {
|
||||||
// TODO use transform script, if any
|
|
||||||
return strings.TrimSpace(value), nil
|
result := sample
|
||||||
|
|
||||||
|
if i.TransformScript != nil {
|
||||||
|
result = result // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(result), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func enrichEnvVariables(cmd *exec.Cmd, variables []string) {
|
func enrichEnvVariables(cmd *exec.Cmd, variables []string) {
|
||||||
|
|
|
@ -108,6 +108,7 @@ func (t *Trigger) evaluate(sample *Sample) bool {
|
||||||
t.consumer.AlertChannel <- &Alert{
|
t.consumer.AlertChannel <- &Alert{
|
||||||
Title: "TRIGGER CONDITION FAILURE",
|
Title: "TRIGGER CONDITION FAILURE",
|
||||||
Text: getErrorMessage(err),
|
Text: getErrorMessage(err),
|
||||||
|
Color: sample.Color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue