common

package
v0.0.0-...-3da42c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProducePrefixedSLI

func ProducePrefixedSLI(prefix string, otherPieces ...string) string

ProducePrefixedSLI concatenates a prefix and pieces to produce a prefixed SLI string.

Types

type KeyValidator

type KeyValidator interface {
	// ValidateKey returns true iff the specified key is allowed within the query.
	ValidateKey(key string) bool
}

KeyValidator interface validates keys within the query.

type KeyValuePairs

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

KeyValuePairs encapsulates a map of keys to values.

func NewKeyValuePairs

func NewKeyValuePairs(keyValues map[string]string) KeyValuePairs

NewKeyValuePairs creates a KeyValuePairs instance from the specified map of keys to values.

func (*KeyValuePairs) Count

func (q *KeyValuePairs) Count() int

Count returns the number of key value pairs.

func (*KeyValuePairs) GetValue

func (q *KeyValuePairs) GetValue(key string) string

GetValue gets the value of a specified key or the zero value if it doesn't exist.

type SLIParser

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

SLIParser parses an un-encoded query string (usually found in sli.yaml files) into key-value pairs.

func NewSLIParser

func NewSLIParser(query string, validator KeyValidator) *SLIParser

NewSLIParser creates a SLIParser for the specified query and validator.

func (*SLIParser) Parse

func (p *SLIParser) Parse() (*KeyValuePairs, error)

Parse parses an un-encoded query string (usually found in sli.yaml files) into KeyValuePairs or returns an error.

type SLIPieces

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

SLIPieces represents the parsed pieces of an SLI, typically created from a ;-delimited string.

func NewSLIPieces

func NewSLIPieces(pieces []string) SLIPieces

NewSLIPieces creates a new SLIPieces from the specified pieces.

func (*SLIPieces) Count

func (p *SLIPieces) Count() int

Count returns the number of pieces.

func (*SLIPieces) Get

func (p *SLIPieces) Get(index int) (string, error)

Get gets the indexed piece.

type SLIPrefixParser

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

SLIPrefixParser parses a query string with ;-delimited prefixes into pieces.

func NewSLIPrefixParser

func NewSLIPrefixParser(sli string, count int) SLIPrefixParser

NewSLIPrefixParser creates a SLIPrefixParser for the specified SLI string and count.

func (SLIPrefixParser) Parse

func (e SLIPrefixParser) Parse() (*SLIPieces, error)

Parse parses the SLI string into number of pieces specified by count. The last piece is the remainder of the input string. An error is returned if the input string contains too few pieces.

type SLIProducer

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

SLIProducer build a SLI string from KeyValuePairs.

func NewSLIProducer

func NewSLIProducer(keyValues KeyValuePairs) *SLIProducer

NewSLIProducer creates a new SLIProducer based on the specified KeyValuePairs and key orderer.

func (*SLIProducer) Produce

func (b *SLIProducer) Produce() string

Produce produces a SLI string based on the KeyValuePairs ordered by key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL