Documentation
¶
Index ¶
- type Bag
- func (bag *Bag) Add(labels ...*Label)
- func (bag *Bag) AddAll(other *Bag)
- func (bag *Bag) Contains(label *Label) bool
- func (bag *Bag) Count(label *Label) int
- func (bag *Bag) Find(label *Label) []*Label
- func (bag *Bag) Labels() []*Label
- func (bag *Bag) Set(label *Label, count int)
- func (bag *Bag) SetAll(other *Bag)
- func (bag *Bag) Size() int
- type Label
- type Template
- type TemplateSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bag ¶
type Bag struct {
// contains filtered or unexported fields
}
Bag represents a bag of labels and their counts, i.e. it is a multi-bag.
func (*Bag) Contains ¶
Contains returns true iff the count of the label is strictly higher than zero.
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents an immutable label which consists of a list of names. Since a label is a list of names the label have a hierarchy, e.g. the labels foo.bar and foo.baz can be thought of as being nested under the label foo.*.
func (*Label) Match ¶
Match returns true iff the label matches the other label or vice versa taking wildcards into account. When matching one label to another label then a wildcard will match any name in the other label at the same position.
type Template ¶
type Template interface { // Bind will bind the template with the given name to the given value. Bind(name, value string) Template // Mappings will return a map of all the current variables and their values. Mappings() map[string]string // Instantiate will create a new label where all templates have been replaced with their currently bound value. Instantiate() *Label }
Template represents a label template which can be instantiated with different values. A template can create labels like schemaless.cluster.percona-cluster-$instance-name$-$zone$-db$cluster$ where the labelTemplate substrings <instance-name>, <zone> and <cluster> can then be bound later, and re-bound to instantiate different labels.
func NewTemplate ¶
NewTemplate will create a new label template which can be used to create labels with. Each name in the slice of supplied names can use template substrings like percona-cluster-$instance-name$-$zone$-db$cluster$ and then later bind the template names <instance-name>, <zone> and <cluster> using the bind method.
type TemplateSet ¶
type TemplateSet interface { // Bind will bind the variable with the given name to the given value. Bind(name, value string) TemplateSet // Add will add a label template whose variables will be set by this variable set. Add(template Template) TemplateSet // AddAll adds all label templates from the given template set to this template set. AddAll(set TemplateSet) TemplateSet // Templates returns all templates of the template set. Templates() []Template // Mappings will return a map of all the current variables and their values. Mappings() map[string]string }
TemplateSet represents a set of label templates where the variables of all templates can be bound for all label templates.
func NewTemplateSet ¶
func NewTemplateSet() TemplateSet
NewTemplateSet will create a new template set where templates can be added and variables can be bound for all templates at the same time.