Documentation ¶
Overview ¶
Package plan provides the Loader singleton that loads metric collection plans.
Index ¶
- func ReadFile(file string) (blip.Plan, error)
- func ReadTable(table string, db *sql.DB, monitorId string) ([]blip.Plan, error)
- func ReadVariable(strVal, planName string) (blip.Plan, error)
- func ValidatePlans(plans []blip.Plan) error
- type Loader
- func (pl *Loader) LoadMonitor(mon blip.ConfigMonitor, dbMaker blip.DbFactory) error
- func (pl *Loader) LoadShared(cfg blip.ConfigPlans, dbMaker blip.DbFactory) error
- func (pl *Loader) MonitorPlans(ids ...string) map[string][]Meta
- func (pl *Loader) Plan(monitorId string, planName string, db *sql.DB) (blip.Plan, error)
- func (pl *Loader) Print()
- func (pl *Loader) SharedPlans() []Meta
- type Meta
- type SortedLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidatePlans ¶
ValidatePlans returns nil if all plans are valid, else it returns an error that lists each validation error.
Types ¶
type Loader ¶
PlanLooader is a singleton service and repo for level plans.
func (*Loader) LoadMonitor ¶
Monitor plans: config.monitors.*.Plans
func (*Loader) LoadShared ¶
LoadShared loads all top-level (shared) plans: config.Plans. These plans are called "shared" because more than one monitor can use them, which is the normal case. For example, the simplest configurate is specifying a single shared plan that almost monitors use implicitly (by not specifcying config.monitors.*.Plans).
This method is called by Server.Boot(). Plans from a table are deferred until the monitor's LPC calls Plan() because the monitor might not be online when Blip starts.
func (*Loader) SharedPlans ¶
type Meta ¶
type Meta struct { Name string Source string YAML string // plan converted to YAML // contains filtered or unexported fields }
Meta is a blip.Plan plus metadata.
type SortedLevel ¶
SortedLevel represents a sorted level created by sortedLevels below.
func Sort ¶
func Sort(p *blip.Plan) []SortedLevel
Sort returns a list of levels sorted (asc) by frequency. Sorted levels are used in the main Run loop: for i := range c.levels. Sorted levels are required because plan levels are unorded because the plan is a map. We could check every level in the plan, but that's wasteful. With sorted levels, we can precisely check which levels to collect at every 1s tick.
Also, plan levels are abbreviated whereas sorted levels are complete. For example, a plan says "collect X every 5s, and collect Y every 10s". But the complete version of that is "collect X every 5s, and collect X + Y every 10s." See "metric inheritance" in the docs.
Also, we convert duration strings from the plan level to integers for sorted levels in order to do modulo (%) in the main Run loop.