Documentation
¶
Index ¶
- Constants
- func Decode(input interface{}, output interface{}) error
- type Capsule
- func (c *Capsule) Delete(key string) (err error)
- func (c *Capsule) Get(key string) json.Result
- func (c *Capsule) GetData() []byte
- func (c *Capsule) GetMetadata() []byte
- func (c *Capsule) Set(key string, value interface{}) (err error)
- func (c *Capsule) SetData(b []byte) *Capsule
- func (c *Capsule) SetMetadata(i interface{}) (*Capsule, error)
- func (c *Capsule) SetRaw(key string, value interface{}) (err error)
- type Config
Constants ¶
const SetInvalidKey = errors.Error("SetInvalidKey")
SetInvalidKey is returned when an invalid key is used in a Capsule Set function.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capsule ¶
type Capsule struct {
// contains filtered or unexported fields
}
Capsule stores encapsulated data that is used throughout the package's data handling and processing functions.
Each capsule contains two unexported fields that are accessed by getters and setters:
- data: stores structured or unstructured data
- metadata: stores structured metadata that describes the data
Values in the metadata field are accessed using the pattern "!metadata [key]". JSON values can be freely moved between the data and metadata fields.
Capsules can be created and initialized using this pattern, where b is a []byte and v is an interface{}:
cap := NewCapsule() cap.SetData(b).SetMetadata(v)
Substation applications follow these rules when handling capsules:
- Sources set the initial metadata, but this can be modified in transit by applying processors
- Sinks only output data, but metadata can be retained by copying it from metadata into data
func (*Capsule) Delete ¶
Delete removes a key from a JSON object stored in the capsule's data or metadata fields.
func (*Capsule) Get ¶
Get retrieves a value from a JSON object stored in the capsule's data or metadata fields.
func (*Capsule) GetMetadata ¶
GetMetadata returns the contents of the capsule's metadata field.
func (*Capsule) Set ¶
Set writes a value to a JSON object stored in the capsule's data or metadata fields.
func (*Capsule) SetMetadata ¶
SetMetadata writes data to the capsule's metadata field. Metadata must be an interface that can marshal to a JSON object.