Documentation ¶
Overview ¶
Package message provides functions for managing data used by conditions and transforms.
Index ¶
- 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) 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) 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) 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 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.