monitor

package
v0.0.0-...-b25ce53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2023 License: AGPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntervalEndsAt

func IntervalEndsAt(period, offset int64, now time.Time) time.Time

IntervalEndsAt returns the time when the interval finish

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

type Count struct {
	Monitor   string
	Unit      string
	Value     uint64
	UUID      string
	Timestamp int64
}

Count contains the info about a group of messages

func ParseCount

func ParseCount(data []byte) *Count

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL