data

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package data (gocollect) holds the collected data to make it ready for submittal.

Package data (gocollect) holds the collected data to make it ready for submittal.

Index

Constants

This section is empty.

Variables

View Source
var BuiltinCollectors = Collectors{}

BuiltinCollectors holds a list of builtin collectors.

Functions

This section is empty.

Types

type Collected

type Collected interface {
	// The same as the io.Reader interface; used when posting data
	// through HTTP.
	Read(p []byte) (n int, err error)

	// Get the data as a string.
	String() string

	// Return voidness of the data.
	IsEmpty() bool

	// Methods that operate on the JSON dictionary.
	GetString(key string) string
	BuildString(template string, extra *map[string]string) string

	// Methods that alter the JSON dictionary.
	SetString(key string, value string) error
}

Collected is the interface to operate on collected data. It molds collected bytes into something that implements HTTP POST method can read. Additionally, it allows alterations of top-level JSON key values.

func EmptyCollected

func EmptyCollected() Collected

EmptyCollected creates a new empty Collected object. Use when there is no data.

func NewCollected

func NewCollected(data []byte) (Collected, error)

NewCollected creates a new Collected object from the supplied bytes.

type Collector

type Collector struct {
	// Callable that should return Collected.
	Run CollectorRun
	// Optional arguments to callable.
	RunArgs string
	// Whether this collector is enabled.
	IsEnabled bool
}

Collector holds instructions how to call a collector.

type CollectorRun

type CollectorRun func(key string, runargs string) Collected

CollectorRun is the function signature to use as the Run function in the Collector struct.

type Collectors

type Collectors map[string]Collector

Collectors holds a key/value map of strings/Collector where key is the collector name and value is the Collector info. For shell script collectors, the Callable is the shell exec function, and RunArgs is the file name.

func MergeCollectors

func MergeCollectors(c1 *Collectors, c2 *Collectors) *Collectors

MergeCollectors merges two lists of collectors and returns a new list. The latter list takes precedence.

func (*Collectors) GetRunnable added in v0.7.4

func (c *Collectors) GetRunnable() (keys []string)

GetRunnable returns all keys that have a runnable/enabled collector in a stable/sorted order. That is, sorted order, but core.id is first.

func (*Collectors) Run

func (c *Collectors) Run(key string) Collected

Run runs/executes the collector and returns the data.

Jump to

Keyboard shortcuts

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