Documentation ¶
Index ¶
- type Bag
- type MutableBag
- func (mb *MutableBag) DebugString() string
- func (mb *MutableBag) Done()
- func (mb *MutableBag) Get(name string) (interface{}, bool)
- func (mb *MutableBag) Merge(bags ...*MutableBag) error
- func (mb *MutableBag) Names() []string
- func (mb *MutableBag) PreserveMerge(bags ...*MutableBag) error
- func (mb *MutableBag) Reset()
- func (mb *MutableBag) Set(name string, value interface{})
- func (mb *MutableBag) ToProto(output *mixerpb.CompressedAttributes, globalDict map[string]int32, ...)
- func (mb *MutableBag) UpdateBagFromProto(attrs *mixerpb.CompressedAttributes, globalWordList []string) error
- type ProtoBag
- func (pb *ProtoBag) ClearReferencedAttributes()
- func (pb *ProtoBag) DebugString() string
- func (pb *ProtoBag) Done()
- func (pb *ProtoBag) Get(name string) (interface{}, bool)
- func (pb *ProtoBag) GetReferencedAttributes(globalDict map[string]int32, globalWordCount int) mixerpb.ReferencedAttributes
- func (pb *ProtoBag) Names() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bag ¶
type Bag interface { // Get returns an attribute value. Get(name string) (value interface{}, found bool) // Names returns the names of all the attributes known to this bag. Names() []string // Done indicates the bag can be reclaimed. Done() // DebugString provides a dump of an attribute Bag that avoids affecting the // calculation of referenced attributes. DebugString() string }
Bag is a generic mechanism to access a set of attributes.
type MutableBag ¶
type MutableBag struct {
// contains filtered or unexported fields
}
MutableBag is a generic mechanism to read and write a set of attributes.
Bags can be chained together in a parent/child relationship. A child bag represents a delta over a parent. By default a child looks identical to the parent. But as mutations occur to the child, the two start to diverge. Resetting a child makes it look identical to its parent again.
func GetBagFromProto ¶
func GetBagFromProto(attrs *mixerpb.CompressedAttributes, globalWordList []string) (*MutableBag, error)
GetBagFromProto returns an initialized bag from an Attribute proto.
func GetFakeMutableBagForTesting ¶
func GetFakeMutableBagForTesting(v map[string]interface{}) *MutableBag
GetFakeMutableBagForTesting returns a Mutable bag based on the specified map Use this function only for testing purposes.
func GetMutableBag ¶
func GetMutableBag(parent Bag) *MutableBag
GetMutableBag returns an initialized bag.
Bags can be chained in a parent/child relationship. You can pass nil if the bag has no parent.
When you are done using the mutable bag, call the Done method to recycle it.
func (*MutableBag) DebugString ¶
func (mb *MutableBag) DebugString() string
DebugString prints out the attributes from the parent bag, then walks through the local changes and prints them as well.
func (*MutableBag) Get ¶
func (mb *MutableBag) Get(name string) (interface{}, bool)
Get returns an attribute value.
func (*MutableBag) Merge ¶
func (mb *MutableBag) Merge(bags ...*MutableBag) error
Merge combines an array of bags into the current bag.
The individual bags may not contain any conflicting attribute values. If that happens, then the merge fails and no mutation will have occurred to the current bag.
func (*MutableBag) Names ¶
func (mb *MutableBag) Names() []string
Names returns the names of all the attributes known to this bag.
func (*MutableBag) PreserveMerge ¶
func (mb *MutableBag) PreserveMerge(bags ...*MutableBag) error
PreserveMerge combines an array of bags into the current bag.
Any conflicting attribute values in the input bags are ignored.
func (*MutableBag) Set ¶
func (mb *MutableBag) Set(name string, value interface{})
Set creates an override for a named attribute.
func (*MutableBag) ToProto ¶
func (mb *MutableBag) ToProto(output *mixerpb.CompressedAttributes, globalDict map[string]int32, globalWordCount int)
ToProto fills-in an Attributes proto based on the content of the bag.
func (*MutableBag) UpdateBagFromProto ¶
func (mb *MutableBag) UpdateBagFromProto(attrs *mixerpb.CompressedAttributes, globalWordList []string) error
UpdateBagFromProto refreshes the bag based on the content of the attribute proto.
Note that in the case of semantic errors in the supplied proto which leads to an error return, it's likely that the bag will have been partially updated.
type ProtoBag ¶
type ProtoBag struct {
// contains filtered or unexported fields
}
ProtoBag implements the Bag interface on top of an Attributes proto.
func NewProtoBag ¶
func NewProtoBag(proto *mixerpb.CompressedAttributes, globalDict map[string]int32, globalWordList []string) *ProtoBag
NewProtoBag creates a new proto-based attribute bag.
func (*ProtoBag) ClearReferencedAttributes ¶
func (pb *ProtoBag) ClearReferencedAttributes()
ClearReferencedAttributes clears the list of referenced attributes being tracked by this bag
func (*ProtoBag) DebugString ¶
DebugString runs through the named attributes, looks up their values, and prints them to a string.
func (*ProtoBag) GetReferencedAttributes ¶
func (pb *ProtoBag) GetReferencedAttributes(globalDict map[string]int32, globalWordCount int) mixerpb.ReferencedAttributes
GetReferencedAttributes returns the set of attributes that have been referenced through this bag.