Open TomTheBear opened 4 months ago
New message processor using expr instead of gval
expr
gval
Can be integrated anywhere to check:
It accepts a json.RawMessage as configuration and parses it. Therefore it can be integrated into other configs:
json.RawMessage
type myConfig struct { Myfield string `json:"myfield"` MessageProcessor json.RawMessage `json:"process_messages"` }
For initialization:
p, err := mp.NewMessageProcessor() if err != nil { return fmt.Errorf("initialization of message processor failed: %v", err.Error()) } err = p.FromConfigJSON(config.MessageProcessor) if err != nil { return fmt.Errorf("failed parsing JSON for message processor: %v", err.Error()) }
Usage:
drop, err := p.ProcessMessage(msg) if err == nil && !drop { // do something with m }
Rules can also be added and removed at runtime using the various Add/Remove functions of p (in the above examples).
Add/Remove
p
Plan is to integrate it in every component that sends or receives messages to filter them based on the configuration.
PrometheusSink
New message processor using
expr
instead ofgval
Can be integrated anywhere to check:
It accepts a
json.RawMessage
as configuration and parses it. Therefore it can be integrated into other configs:For initialization:
Usage:
Rules can also be added and removed at runtime using the various
Add/Remove
functions ofp
(in the above examples).Plan is to integrate it in every component that sends or receives messages to filter them based on the configuration.
PrometheusSink
(as an example)