pdk

package
v0.0.0-...-c496913 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyPresentValues

func CopyPresentValues(source, target map[string]interface{}, keys []string)

* Go through the list "keys" and copy "source" maps's values, * if such exist, into the "target". * * To be able to copy a field value of the internal child maps - * it's possible to specify a dot in a key name, function will split the * name by dots and try to find the expected internal map and it's field value. * * Example: * * The source: { * "x": 10, * "y": { * "z": "hello" * }, * "n.m": "world" * } * * Keys to copy: * * x - will copy the value "10" * y.z - will copy the value "hello" * n.m - will copy the value "world", as there is no internal map "n"

func CreateRelations

func CreateRelations(source *Source, entry map[string]interface{}, unique map[string]bool, counter *int, mx *sync.Mutex, results *[]map[string]interface{})

* Create relations from a data source response's single entry

func IntSliceContains

func IntSliceContains(slice []int, val int) bool

* Check whether the slice contains the given integer

func InterfaceSliceContains

func InterfaceSliceContains(slice []interface{}, val interface{}) bool

* Check whether the slice contains the given interface

func ResultsContain

func ResultsContain(results []map[string]interface{}, entry map[string]interface{}, relation *Relation) bool

* Check whether current entry is identical to any of * the already collected unique results. * * This returns to the user only unique entries from a data source. * If single relation's From.ID == To.ID, but even one attribute is different - * JavaScript-side will get both entries and merge their attributes

func StringSliceContains

func StringSliceContains(slice []string, val string) bool

* Check whether the slice contains the given string

Types

type Node

type Node struct {
	ID         string   `yaml:"id"`
	Group      string   `yaml:"group"`
	Search     string   `yaml:"search"`
	Attributes []string `yaml:"attributes"`
	VarTypes   []*struct {
		Regex         string         `yaml:"regex"`
		RegexCompiled *regexp.Regexp `yaml:"-"`
		Group         string         `yaml:"group"`
		Search        string         `yaml:"search"`
		Label         string         `yaml:"label"`
	} `yaml:"varTypes"`
}

type Processor

type Processor struct {
	Name    string                 `yaml:"name"`
	Plugin  string                 `yaml:"plugin"`
	Timeout time.Duration          `yaml:"timeout"`
	Data    map[string]interface{} `yaml:"data"`
}

type ProcessorPlugin

type ProcessorPlugin interface {
	// Return instance configuration
	Conf() *Processor

	// Set specific parameters for the instance,
	// establish connection, etc.
	Setup(*Processor) error

	// Process data source's received data in a background
	Process([]map[string]interface{}) ([]map[string]interface{}, error)

	// Stop the processor when the core service stops,
	// gracefully disconnect if needed
	Stop() error
}

* Plugin interface to be implemented by the processor plugins

type Relation

type Relation struct {
	From *Node `yaml:"from"`
	To   *Node `yaml:"to"`
	Edge *struct {
		Label      string   `yaml:"label"`
		Attributes []string `yaml:"attributes"`
	} `yaml:"edge"`
}

type Source

type Source struct {
	Name            string            `yaml:"name"`
	Label           string            `yaml:"label"`
	Icon            string            `yaml:"icon"`
	Plugin          string            `yaml:"plugin"`
	InGlobal        bool              `yaml:"inGlobal"`
	IncludeDatetime bool              `yaml:"includeDatetime"`
	SupportsSQL     bool              `yaml:"supportsSQL"`
	Timeout         time.Duration     `yaml:"timeout"`
	Access          map[string]string `yaml:"access"`
	QueryFields     []string          `yaml:"queryFields"`
	IncludeFields   []string          `yaml:"includeFields"`
	StatsFields     []string          `yaml:"statsFields"`
	ReplaceFields   map[string]string `yaml:"replaceFields"`
	Relations       []*Relation       `yaml:"relations"`
}

type SourcePlugin

type SourcePlugin interface {
	// Return data source instance configuration
	Conf() *Source

	// Set specific parameters for the data source instance,
	// establish connection, etc.
	Setup(*Source, int) error

	// Get a list of all known data source's fields
	// for the Web GUI autocomplete
	Fields() ([]string, error)

	// Execute the given query.
	// Returns results, statistics, debug info & error
	Search(*sqlparser.Select) ([]map[string]interface{}, map[string]interface{}, map[string]interface{}, error)

	// Stop the collector when the core service stops,
	// gracefully disconnect from the data source if needed
	Stop() error
}

* Plugin interface to be implemented by the data source plugins

type Stats

type Stats struct {
	Fields map[string]*sortedmap.SortedMap
	// contains filtered or unexported fields
}

* Structure to contain statistics data * if some data source has too many entries to return * (above the preconfigured limit)

func NewStats

func NewStats() *Stats

func (*Stats) ToJSON

func (s *Stats) ToJSON(source string) (map[string]interface{}, error)

* Convert sorted-map object to the native map, * converted to the JSON later, * so the Web GUI can draw interactive charts. * * Receives a data source name

func (*Stats) Update

func (s *Stats) Update(entry map[string]interface{}, key string)

* Update statistics of the received entries from some data source. * When the amount of returned entries becomes too large * users will receive the statistics info instead of the graph relations data. * * Receives: * entry - single entry from a data source * key - statistics chart field to update, * one entry increases the value by 1

Jump to

Keyboard shortcuts

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