pkg: istio.io/pkg/attribute Index | Files

package attribute

import "istio.io/pkg/attribute"

Package attribute is focused on enabling efficient handling and tracking of attribute usage.

Index

Package Files

bag.go doc.go emptyBag.go expression.go finder.go list.go mutableBag.go reference.go stringmap.go

func CheckType Uses

func CheckType(value interface{}) bool

CheckType validates that an attribute value has a supported type.

func Equal Uses

func Equal(this, that interface{}) bool

Equal compares two attribute values.

type AttributeDescriptorFinder Uses

type AttributeDescriptorFinder interface {
    // GetAttribute finds attribute descriptor in the vocabulary. returns nil if not found.
    GetAttribute(name string) *configpb.AttributeManifest_AttributeInfo
    // Attributes exposes the internal attribute manifest
    Attributes() map[string]*configpb.AttributeManifest_AttributeInfo
}

AttributeDescriptorFinder finds attribute descriptors. nolint: golint

func NewChainedFinder Uses

func NewChainedFinder(parent AttributeDescriptorFinder, overrides map[string]*configpb.AttributeManifest_AttributeInfo) AttributeDescriptorFinder

NewChainedFinder returns an attribute finder that delegates to a parent finder with some overrides.

func NewFinder Uses

func NewFinder(attributes map[string]*configpb.AttributeManifest_AttributeInfo) AttributeDescriptorFinder

NewFinder returns a new AttributeDescriptorFinder instance, based on the given attributes

type Bag Uses

type Bag interface {
    fmt.Stringer

    // 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

    // Contains returns true if this bag contains the specified key.
    Contains(key string) bool

    // Done indicates the bag can be reclaimed.
    Done()

    // ReferenceTracker keeps track of bag accesses (optionally)
    ReferenceTracker() ReferenceTracker
}

Bag is a generic mechanism to access a set of attributes.

The type of an attribute value is guaranteed to be one of the following: - int64 - string - float64 - bool - time.Time - time.Duration - []byte (backed by a byte array) - attribute.StringMap (backed by a map[string]string)

Attribute value types are physical representation of the semantic attribute types. For example, IP addresses are represented as []byte.

The following types are not fully implemented at the surface level: - *attribute.List (note the pointer, backed by []interface{})

type Expression Uses

type Expression interface {
    // Evaluate evaluates this compiled expression against the attribute bag.
    Evaluate(attributes Bag) (interface{}, error)

    // EvaluateBoolean evaluates this compiled expression against the attribute bag and returns the result as boolean.
    // panics if the expression does not return a boolean.
    EvaluateBoolean(attributes Bag) (bool, error)

    // EvaluateString evaluates this compiled expression against the attribute bag and returns the result as string.
    // panics if the expression does not return a string.
    EvaluateString(attributes Bag) (string, error)

    // EvaluateDouble evaluates this compiled expression against the attribute bag and returns the result as float64.
    // panics if the expression does not return a float64.
    EvaluateDouble(attribute Bag) (float64, error)

    // EvaluateInteger evaluates this compiled expression against the attribute bag and returns the result as int64.
    // panics if the expression does not return a int64.
    EvaluateInteger(attribute Bag) (int64, error)
}

Expression represents a precompiled expression that can be immediately evaluated. It holds no cache and does not listen to any events. If the configuration changes, the CompiledExpression needs to be discarded and created again.

type List Uses

type List struct {
    // contains filtered or unexported fields
}

List wraps a list of values and optionally reference counts it

func NewList Uses

func NewList(name string) *List

NewList creates a new list

func NewListForTesting Uses

func NewListForTesting(name string, entries []interface{}) *List

NewListForTesting should only be used for testing.

func (*List) Append Uses

func (l *List) Append(val interface{})

Append mutates a list by appending an element to the end.

func (*List) Equal Uses

func (l *List) Equal(m *List) bool

Equal compares the list entries

func (*List) String Uses

func (l *List) String() string

String returns the string representation of the entries in the list

type MutableBag Uses

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 CopyBag Uses

func CopyBag(b Bag) *MutableBag

CopyBag makes a deep copy of a bag.

func GetMutableBag Uses

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 GetMutableBagForTesting Uses

func GetMutableBagForTesting(values map[string]interface{}) *MutableBag

GetMutableBagForTesting returns a Mutable bag based on the specified map Use this function only for testing purposes.

func (*MutableBag) Contains Uses

func (mb *MutableBag) Contains(key string) bool

Contains returns true if the key is present in the bag.

func (*MutableBag) Delete Uses

func (mb *MutableBag) Delete(name string)

Delete removes a named item from the local state. The item may still be present higher in the hierarchy

func (*MutableBag) Done Uses

func (mb *MutableBag) Done()

Done indicates the bag can be reclaimed.

func (*MutableBag) Get Uses

func (mb *MutableBag) Get(name string) (interface{}, bool)

Get returns an attribute value.

func (*MutableBag) Merge Uses

func (mb *MutableBag) Merge(bag *MutableBag)

Merge combines an array of bags into the current bag. If the current bag already defines a particular attribute, it keeps its value and is not overwritten.

Note that this does a 'shallow' merge. Only the value defined explicitly in the mutable bags themselves, and not in any of their parents, are considered.

func (*MutableBag) Names Uses

func (mb *MutableBag) Names() []string

Names returns the names of all the attributes known to this bag.

func (*MutableBag) ReferenceTracker Uses

func (mb *MutableBag) ReferenceTracker() ReferenceTracker

ReferenceTracker keeps track of bag accesses (optionally)

func (*MutableBag) Reset Uses

func (mb *MutableBag) Reset()

Reset removes all local state.

func (*MutableBag) Set Uses

func (mb *MutableBag) Set(name string, value interface{})

Set creates an override for a named attribute.

func (*MutableBag) String Uses

func (mb *MutableBag) String() string

String prints out the attributes from the parent bag, then walks through the local changes and prints them as well.

type Presence Uses

type Presence int32

Presence keeps tracks of the attribute reference outcome.

const (
    ConditionUnspecified Presence = 0
    Absence              Presence = 1
    Exact                Presence = 2
    Regex                Presence = 3
)

Values for the presence

type Reference Uses

type Reference struct {
    Name   string
    MapKey string
}

Reference is a reference to an attribute.

type ReferenceTracker Uses

type ReferenceTracker interface {
    // MapReference records access of a string map record.
    MapReference(name, key string, condition Presence)

    // Reference records access of an attribute by name.
    Reference(name string, condition Presence)

    // Clear the list of referenced attributes being tracked by this bag
    Clear()

    // Restore the list of referenced attributes being tracked by this bag
    Restore(snap ReferencedAttributeSnapshot)

    // Snapshot grabs a snapshot of the currently referenced attributes
    Snapshot() ReferencedAttributeSnapshot
}

ReferenceTracker for an attribute bag

type ReferencedAttributeSnapshot Uses

type ReferencedAttributeSnapshot struct {
    // ReferenceAttrs is a collection of references to attributes
    ReferencedAttrs map[Reference]Presence
}

ReferencedAttributeSnapshot keeps track of the attribute reference state for a mutable bag. You can snapshot the referenced attributes with SnapshotReferencedAttributes and later reinstall them with RestoreReferencedAttributes. Note that a snapshot can only be used once, the RestoreReferencedAttributes call is destructive.

type StringMap Uses

type StringMap struct {
    // contains filtered or unexported fields
}

StringMap wraps a map[string]string and optionally reference counts it

func NewStringMap Uses

func NewStringMap(name string, entries map[string]string, owner Bag) StringMap

NewStringMap instantiates a new string map. The stringmap takes ownership of the provided map.

func WrapStringMap Uses

func WrapStringMap(entries map[string]string) StringMap

WrapStringMap wraps a string map value without reference tracking.

func (StringMap) Entries Uses

func (s StringMap) Entries() map[string]string

Entries returns the wrapped string map.

func (StringMap) Equal Uses

func (s StringMap) Equal(t StringMap) bool

Equal compares the string map entries

func (StringMap) Get Uses

func (s StringMap) Get(key string) (string, bool)

Get returns a stringmap value and records access

func (StringMap) Set Uses

func (s StringMap) Set(key, val string)

Set wraps a string map set operation.

func (StringMap) String Uses

func (s StringMap) String() string

String returns a string representation of the entries in the string map

Package attribute imports 8 packages (graph) and is imported by 54 packages. Updated 2019-05-17. Refresh now. Tools for package owners.