Help us shape the future of Go! Take the 2026 Go Developer Survey

formatters

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventProcessorTypes = []string{
	"event-add-tag",
	"event-allow",
	"event-convert",
	"event-date-string",
	"event-delete",
	"event-drop",
	"event-extract-tags",
	"event-jq",
	"event-merge",
	"event-override-ts",
	"event-strings",
	"event-to-tag",
	"event-trigger",
	"event-write",
	"event-group-by",
	"event-data-convert",
	"event-value-tag",
}
View Source
var EventProcessors = map[string]Initializer{}

Functions

func CheckCondition added in v0.10.0

func CheckCondition(code *gojq.Code, e *EventMsg) (bool, error)

func DecodeConfig

func DecodeConfig(src, dst interface{}) error

func Register

func Register(name string, initFn Initializer)

func ResponsesFlat added in v0.14.0

func ResponsesFlat(msgs ...proto.Message) (map[string]interface{}, error)

func TagsFromGNMIPath

func TagsFromGNMIPath(p *gnmi.Path) (string, map[string]string)

TagsFromGNMIPath returns a string representation of the gNMI path without keys, as well as a map of the keys in the path. the key map will also contain a target value if present in the gNMI path.

Types

type EventMsg

type EventMsg struct {
	Name      string                 `json:"name,omitempty"`
	Timestamp int64                  `json:"timestamp,omitempty"`
	Tags      map[string]string      `json:"tags,omitempty"`
	Values    map[string]interface{} `json:"values,omitempty"`
	Deletes   []string               `json:"deletes,omitempty"`
}

EventMsg represents a gNMI update message, The name is derived from the subscription in case the update was received in a subscribeResponse the tags are derived from the keys in gNMI path as well as some metadata from the subscription.

func EventFromMap added in v0.9.1

func EventFromMap(m map[string]interface{}) (*EventMsg, error)

func GetResponseToEventMsgs added in v0.21.0

func GetResponseToEventMsgs(rsp *gnmi.GetResponse, meta map[string]string, eps ...EventProcessor) ([]*EventMsg, error)

func ResponseToEventMsgs

func ResponseToEventMsgs(name string, rsp *gnmi.SubscribeResponse, meta map[string]string, eps ...EventProcessor) ([]*EventMsg, error)

ResponseToEventMsgs //

func (*EventMsg) String added in v0.25.0

func (e *EventMsg) String() string

func (*EventMsg) ToMap added in v0.9.1

func (e *EventMsg) ToMap() map[string]interface{}

type EventProcessor

type EventProcessor interface {
	Init(interface{}, ...Option) error
	Apply(...*EventMsg) []*EventMsg

	WithTargets(map[string]*types.TargetConfig)
	WithLogger(l *log.Logger)
	WithActions(act map[string]map[string]interface{})
}

type Initializer

type Initializer func() EventProcessor

type MarshalOptions

type MarshalOptions struct {
	Multiline  bool // could get rid of this and deduct it from len(Indent)
	Indent     string
	Format     string
	OverrideTS bool
	ValuesOnly bool
}

func (*MarshalOptions) FormatJSON

func (o *MarshalOptions) FormatJSON(m proto.Message, meta map[string]string) ([]byte, error)

FormatJSON formats a proto.Message and returns a []byte and an error

func (*MarshalOptions) Marshal

func (o *MarshalOptions) Marshal(msg proto.Message, meta map[string]string, eps ...EventProcessor) ([]byte, error)

Marshal //

func (*MarshalOptions) OverrideTimestamp added in v0.14.1

func (o *MarshalOptions) OverrideTimestamp(msg proto.Message) proto.Message

type NotificationRspMsg

type NotificationRspMsg struct {
	Meta             map[string]interface{} `json:"meta,omitempty"`
	Source           string                 `json:"source,omitempty"`
	SystemName       string                 `json:"system-name,omitempty"`
	SubscriptionName string                 `json:"subscription-name,omitempty"`
	Timestamp        int64                  `json:"timestamp,omitempty"`
	Time             *time.Time             `json:"time,omitempty"`
	Prefix           string                 `json:"prefix,omitempty"`
	Target           string                 `json:"target,omitempty"`
	Updates          []update               `json:"updates,omitempty"`
	Deletes          []string               `json:"deletes,omitempty"`
}

type Option added in v0.9.1

type Option func(EventProcessor)

func WithActions added in v0.21.0

func WithActions(acts map[string]map[string]interface{}) Option

func WithLogger added in v0.9.1

func WithLogger(l *log.Logger) Option

func WithTargets added in v0.9.1

func WithTargets(tcs map[string]*types.TargetConfig) Option

Jump to

Keyboard shortcuts

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