starlark

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldDictMethods = map[string]builtinMethod{
	"clear":      dictClear,
	"get":        dictGet,
	"items":      dictItems,
	"keys":       dictKeys,
	"pop":        dictPop,
	"popitem":    dictPopitem,
	"setdefault": dictSetdefault,
	"update":     dictUpdate,
	"values":     dictValues,
}
View Source
var TagDictMethods = map[string]builtinMethod{
	"clear":      dictClear,
	"get":        dictGet,
	"items":      dictItems,
	"keys":       dictKeys,
	"pop":        dictPop,
	"popitem":    dictPopitem,
	"setdefault": dictSetdefault,
	"update":     dictUpdate,
	"values":     dictValues,
}

Functions

func LoadFunc

func LoadFunc(module string, logger telegraf.Logger) (starlark.StringDict, error)

func LogModule

func LogModule(logger telegraf.Logger) *starlarkstruct.Module

Builds a module that defines all the supported logging functions which will log using the provided logger

Types

type Common added in v1.24.3

type Common struct {
	Source    string                 `toml:"source"`
	Script    string                 `toml:"script"`
	Constants map[string]interface{} `toml:"constants"`

	Log              telegraf.Logger `toml:"-"`
	StarlarkLoadFunc func(module string, logger telegraf.Logger) (starlark.StringDict, error)
	// contains filtered or unexported fields
}

func (*Common) AddFunction added in v1.24.3

func (s *Common) AddFunction(name string, params ...starlark.Value) error

func (*Common) Call added in v1.24.3

func (s *Common) Call(name string) (starlark.Value, error)

Call calls the function corresponding to the given name.

func (*Common) GetParameters added in v1.24.3

func (s *Common) GetParameters(name string) (starlark.Tuple, bool)

func (*Common) Init added in v1.24.3

func (s *Common) Init() error

func (*Common) LogError added in v1.24.3

func (s *Common) LogError(err error)

type FieldDict

type FieldDict struct {
	*Metric
}

FieldDict is a starlark.Value for the metric fields. It is heavily based on the starlark.Dict.

func (FieldDict) Attr

func (d FieldDict) Attr(name string) (starlark.Value, error)

Attr implements the starlark.HasAttrs interface.

func (FieldDict) AttrNames

func (d FieldDict) AttrNames() []string

AttrNames implements the starlark.HasAttrs interface.

func (FieldDict) Clear

func (d FieldDict) Clear() error

func (FieldDict) Delete

func (d FieldDict) Delete(k starlark.Value) (v starlark.Value, found bool, err error)

func (FieldDict) Freeze

func (d FieldDict) Freeze()

func (FieldDict) Get

func (d FieldDict) Get(key starlark.Value) (v starlark.Value, found bool, err error)

Get implements the starlark.Mapping interface.

func (FieldDict) Hash

func (d FieldDict) Hash() (uint32, error)

func (FieldDict) Items

func (d FieldDict) Items() []starlark.Tuple

Items implements the starlark.IterableMapping interface.

func (FieldDict) Iterate

func (d FieldDict) Iterate() starlark.Iterator

Iterate implements the starlark.Iterator interface.

func (FieldDict) PopItem

func (d FieldDict) PopItem() (starlark.Value, error)

func (FieldDict) SetKey

func (d FieldDict) SetKey(k, v starlark.Value) error

SetKey implements the starlark.HasSetKey interface to support map update using x[k]=v syntax, like a dictionary.

func (FieldDict) String

func (d FieldDict) String() string

func (FieldDict) Truth

func (d FieldDict) Truth() starlark.Bool

func (FieldDict) Type

func (d FieldDict) Type() string

type FieldIterator

type FieldIterator struct {
	*Metric
	// contains filtered or unexported fields
}

func (*FieldIterator) Done

func (i *FieldIterator) Done()

Done implements the starlark.Iterator interface.

func (*FieldIterator) Next

func (i *FieldIterator) Next(p *starlark.Value) bool

Next implements the starlark.Iterator interface.

type Metric

type Metric struct {
	// contains filtered or unexported fields
}

func (*Metric) Attr

func (m *Metric) Attr(name string) (starlark.Value, error)

Attr implements the starlark.HasAttrs interface.

func (*Metric) AttrNames

func (m *Metric) AttrNames() []string

AttrNames implements the starlark.HasAttrs interface.

func (*Metric) Fields

func (m *Metric) Fields() FieldDict

func (*Metric) Freeze

func (m *Metric) Freeze()

func (*Metric) Hash

func (m *Metric) Hash() (uint32, error)

func (*Metric) Name

func (m *Metric) Name() starlark.String

func (*Metric) SetField

func (m *Metric) SetField(name string, value starlark.Value) error

SetField implements the starlark.HasSetField interface.

func (*Metric) SetName

func (m *Metric) SetName(value starlark.Value) error

func (*Metric) SetTime

func (m *Metric) SetTime(value starlark.Value) error

func (*Metric) String

func (m *Metric) String() string

String returns the starlark representation of the Metric.

The String function is called by both the repr() and str() functions, and so it behaves more like the repr function would in Python.

func (*Metric) Tags

func (m *Metric) Tags() TagDict

func (*Metric) Time

func (m *Metric) Time() starlark.Int

func (*Metric) Truth

func (m *Metric) Truth() starlark.Bool

func (*Metric) Type

func (m *Metric) Type() string

func (*Metric) Unwrap

func (m *Metric) Unwrap() telegraf.Metric

Unwrap removes the telegraf.Metric from the startlark.Metric.

func (*Metric) Wrap

func (m *Metric) Wrap(metric telegraf.Metric)

Wrap updates the starlark.Metric to wrap a new telegraf.Metric.

type TagDict

type TagDict struct {
	*Metric
}

TagDict is a starlark.Value for the metric tags. It is heavily based on the starlark.Dict.

func (TagDict) Attr

func (d TagDict) Attr(name string) (starlark.Value, error)

Attr implements the starlark.HasAttrs interface.

func (TagDict) AttrNames

func (d TagDict) AttrNames() []string

AttrNames implements the starlark.HasAttrs interface.

func (TagDict) Clear

func (d TagDict) Clear() error

func (TagDict) Delete

func (d TagDict) Delete(k starlark.Value) (v starlark.Value, found bool, err error)

func (TagDict) Freeze

func (d TagDict) Freeze()

func (TagDict) Get

func (d TagDict) Get(key starlark.Value) (v starlark.Value, found bool, err error)

Get implements the starlark.Mapping interface.

func (TagDict) Hash

func (d TagDict) Hash() (uint32, error)

func (TagDict) Items

func (d TagDict) Items() []starlark.Tuple

Items implements the starlark.IterableMapping interface.

func (TagDict) Iterate

func (d TagDict) Iterate() starlark.Iterator

Iterate implements the starlark.Iterator interface.

func (TagDict) PopItem

func (d TagDict) PopItem() (v starlark.Value, err error)

func (TagDict) SetKey

func (d TagDict) SetKey(k, v starlark.Value) error

SetKey implements the starlark.HasSetKey interface to support map update using x[k]=v syntax, like a dictionary.

func (TagDict) String

func (d TagDict) String() string

func (TagDict) Truth

func (d TagDict) Truth() starlark.Bool

func (TagDict) Type

func (d TagDict) Type() string

type TagIterator

type TagIterator struct {
	*Metric
	// contains filtered or unexported fields
}

func (*TagIterator) Done

func (i *TagIterator) Done()

Done implements the starlark.Iterator interface.

func (*TagIterator) Next

func (i *TagIterator) Next(p *starlark.Value) bool

Next implements the starlark.Iterator interface.

Jump to

Keyboard shortcuts

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