Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alert ¶
type Alert struct { Monitor string `json:"monitor"` Type string `json:"type"` UUID string `json:"uuid,omitempty"` CurrentBytes uint64 `json:"current_bytes,omitempty"` Limit uint64 `json:"limit,omitempty"` Timestamp int64 `json:"timestamp"` Licenses []string `json:"licenses,omitempty"` }
Alert contains the information abot a message alerting that the maximum number of messages has been reached.
type Config ¶
type Config struct { Limits map[string]uint64 Period int64 Offset int64 Workers int Log logger // contains filtered or unexported fields }
Config contains the configuration for a Monitor.
type Count ¶
Count contains the info about a group of messages
func ParseCount ¶
ParseCount gets a json as a map and returns a struct with the values
type CountersMonitor ¶
type CountersMonitor struct { Config // contains filtered or unexported fields }
CountersMonitor process count messages and check if the maximum of allowed messages has been reached.
func (*CountersMonitor) OnMessage ¶
func (mon *CountersMonitor) OnMessage(m *utils.Message, done utils.Done)
OnMessage process new messages.
- Parses the JSON message and check if the UUID is on the limits database, if not, a message alerting an unknown uuid is sent to kafka.
- If the UUID is known (is on the limit map), increment the count of messages on the internal database.
- Check if the updated value exceds the allowed number of bytes and if it does, send an alert to Kafka.
func (*CountersMonitor) Spawn ¶
func (mon *CountersMonitor) Spawn(id int) utils.Composer
Spawn creates a new instance of a Monitor.
func (*CountersMonitor) Workers ¶
func (mon *CountersMonitor) Workers() int
Workers returns the number of workers.
Click to show internal directories.
Click to hide internal directories.