Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterProbeType ¶
func RegisterProbeType(ptype string, pfunc probeParserFunc)
Types ¶
type Probe ¶
type Probe struct {
// contains filtered or unexported fields
}
A Probe holds all the runtime information necessary to run a single probe, combining the SpecCommon parameters with a ProbeImpl to actually execute the probe.
func ParseConfig ¶
func ParseConfig(data []byte, resultStore ResultStore) ([]*Probe, error)
ParseConfig parses a JSON-encoded configuration and returns a list of Probe objects that can be executed or sent to the scheduler.
Configuration parsing has a few phases: decoding the configuration itself is a relatively complex task, as we are implementing polymorphysm on probe definitions (via their "params" attribute).This requires a multi-level approach in Go, where JSON parsing is split into generic / specific stages, with the latter delegated to a type-specific parser accessed via a global registry. The result of this process is a "template" probe called a Spec, which has to be an interface type because the actual struct definition is private to the specific probe implementation.
Then, parameterization is applied, potentially generating multiple Probes from each Spec. Variables are expanded, and all necessary information is bound together in the runtime-ready Probe object. The variable expansion process is reflect-heavy but is only performed once at the start of the process. The resulting Probe objects are minimal and lean.
type Result ¶
type Result struct { ID string Spec SpecCommon Ok bool Error string Start time.Time Duration time.Duration Logs string }
Result of the execution of a probe.
type ResultStore ¶
type ResultStore interface { Push(*Result) Each(func(*Result)) EachErrs(func(*Result)) Find(string) *Result }
ResultStore keeps the most recent probe results in storage, and allows access to them (mostly for debugging purposes, as this part isn't required by the prober functionality). The results buffer has a fixed size, so older results will be dropped as more recent ones come in. Failures are kept in a separate buffer, with the hope of keeping errors around for longer for inspection purposes, even after they've recovered.
func NewInstrumentedResultStore ¶
func NewInstrumentedResultStore(wrap ResultStore) ResultStore
func NewResultStore ¶
func NewResultStore(numOk, numErrs int) ResultStore
type SpecCommon ¶
type SpecCommon struct { Type string `json:"type"` Name string `json:"name"` Loop []string `json:"loop"` Labels map[string]string `json:"labels"` Interval jsontypes.Duration `json:"interval"` Timeout jsontypes.Duration `json:"timeout"` }
SpecCommon holds the parameters common to all probe specifications.