Documentation ¶
Overview ¶
Package message provides functions for managing data used by conditions and transforms.
Index ¶
- type Flag
- type Message
- func (m *Message) AsControl() *Message
- func (m *Message) Data() []byte
- func (m *Message) DeleteValue(key string) error
- func (m *Message) GetValue(key string) Value
- func (m *Message) HasFlag(i Flag) bool
- func (m *Message) IsControl() bool
- func (m *Message) Metadata() []byte
- func (m *Message) SetData(data []byte) *Message
- func (m *Message) SetMetadata(metadata []byte) *Message
- func (m *Message) SetValue(key string, value interface{}) error
- func (m *Message) SkipEmptyValues() *Message
- func (m *Message) SkipMissingValues() *Message
- func (m *Message) SkipNullValues() *Message
- func (m *Message) String() string
- type Value
- func (v Value) Array() []Value
- func (v Value) Bool() bool
- func (v Value) Bytes() []byte
- func (v Value) Exists() bool
- func (v Value) Float() float64
- func (v Value) Int() int64
- func (v Value) IsArray() bool
- func (v Value) IsEmpty() bool
- func (v Value) IsMissing() bool
- func (v Value) IsNull() bool
- func (v Value) IsObject() bool
- func (v Value) Map() map[string]Value
- func (v Value) String() string
- func (v Value) Uint() uint64
- func (v Value) Value() any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flag ¶ added in v2.3.0
type Flag int
const ( // IsControl indicates that the message is a control message. IsControl Flag = iota // SkipNullValues indicates that null values should be ignored when processing the message. SkipNullValues // SkipMissingValues indicates that missing values should be ignored when processing the message. SkipMissingValues // SkipEmptyValues indicates that empty values should be ignored when processing the message. SkipEmptyValues )
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is the data structure that is handled by transforms and interpreted by conditions.
Data in each message can be accessed and modified as JSON text or binary data:
- JSON text is accessed using the GetValue, SetValue, and DeleteValue methods.
- Binary data is accessed using the Data and SetData methods.
Metadata is an additional data field that is meant to store information about the message, but can be used for any purpose. For JSON text, metadata is accessed using the GetValue, SetValue, and DeleteValue methods with a key prefixed with "meta" (e.g. "meta foo"). Binary metadata is accessed using the Metadata and SetMetadata methods.
Messages can also be configured as "control messages." Control messages are used for flow control in Substation functions and applications, but can be used for any purpose depending on the needs of a transform or condition. These messages should not contain data or metadata.
func (*Message) DeleteValue ¶
DeleteValue deletes a value in the message data or metadata.
If the key is prefixed with "meta" (e.g. "meta foo"), then the value is removed from the metadata field, otherwise it is removed from the data field.
This only works with JSON text. If the message data or metadata is not JSON text, then this method does nothing.
func (*Message) GetValue ¶
GetValue returns a value from the message data or metadata.
If the key is prefixed with "meta" (e.g. "meta foo"), then the value is retrieved from the metadata field, otherwise it is retrieved from the data field.
This only works with JSON text. If the message data or metadata is not JSON text, then an empty value is returned.
func (*Message) SetMetadata ¶
SetMetadata sets the message metadata.
func (*Message) SetValue ¶
SetValue sets a value in the message data or metadata.
If the key is prefixed with "meta" (e.g. "meta foo"), then the value is placed into the metadata field, otherwise it is placed into the data field.
This only works with JSON text. If the message data or metadata is not JSON text, then this method does nothing.
func (*Message) SkipEmptyValues ¶ added in v2.3.0
func (*Message) SkipMissingValues ¶ added in v2.3.0
func (*Message) SkipNullValues ¶ added in v2.3.0
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a wrapper around gjson.Result that provides a consistent interface for converting values from JSON text.
func (Value) IsEmpty ¶ added in v2.3.0
IsEmpty returns true if the value is an empty string, empty array, empty object, or null.