model

package
v0.0.0-...-fabe767 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeNameRE = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_]*$")

SchemaNameRE is a regular expression matching valid label names. Note that the IsValid method of SchemaName performs the same check but faster than a match with this regular expression.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	// The name of an attribute, must be unique for the resource level and cannot be null or empty.
	Name         promModel.LabelName
	StringRecord `yaml:",inline" json:",inline"`
}

Attribute is a Key-value struct for describe a property of the resource, and can be used for resources selection.

type AttributeSchema

type AttributeSchema struct {
	Name     promModel.LabelName // id
	Brief    string              // comment
	Type     string              // string,int...
	Required bool
}

type HistoricalAttribute

type HistoricalAttribute struct {
	Name    promModel.LabelName `json:",omitempty"`
	Records []*StringRecord     `json:",omitempty"`
}

type HistoricalRelation

type HistoricalRelation struct {
	RelationName         `json:",inline" yaml:",inline"`
	SourceUrn, TargetUrn string
	Records              []*RelationChangedRecord
}

type HistoricalResource

type HistoricalResource struct {
	Type         TypeName   `json:",omitempty"` // Related with resource's type, and the type connected with a specification.
	Urn          string     `json:",omitempty"` // The Unique resource name of this resources, must be unique with whole scope.
	ObserveTypes []TypeName `json:",omitempty"` // Additional type of resource, used for observability.

	Attributes []*HistoricalAttribute `json:",omitempty"` // Attributes of the resource, may be a required or optional.
	State      *HistoricalState       `json:",omitempty"` // State of the resource, name should be unique.
}

type HistoricalState

type HistoricalState struct {
	Name    promModel.LabelName
	Records []*StateRecord
}

type Relation

type Relation struct {
	RelationName          `json:",inline" yaml:",inline"`
	SourceUrn, TargetUrn  string
	RelationChangedRecord `json:",inline" yaml:",inline"`
}

Relation is the data represent dependency of resources

func (Relation) String

func (r Relation) String() string

func (Relation) TypeName

func (r Relation) TypeName() TypeName

type RelationChangedRecord

type RelationChangedRecord struct {
	Since promModel.Time // The time of relation created.
	EndUp promModel.Time // The time of relation finished.
}

type RelationConditionSchema

type RelationConditionSchema struct {
	SourceAttribute promModel.LabelName
	TargetAttribute promModel.LabelName
}

type RelationName

type RelationName struct {
	Name, Source, Target TypeName
}

type RelationSchema

type RelationSchema struct {
	Name           promModel.LabelName
	Brief          string
	Source, Target ResourceSchema
	Conditions     []*RelationConditionSchema
}

type Resource

type Resource struct {
	Type         TypeName     `json:",omitempty"` // Related with resource's type, and the type connected with a specification.
	Urn          string       `json:",omitempty"` // The Unique resource name of this resources, must be unique with whole scope.
	ObserveTypes []TypeName   `json:",omitempty"` // Additional type of resource, used for observability.
	Attributes   []*Attribute `json:",omitempty"` // Attributes of the resource, may be a required or optional.
	States       *State       `json:",omitempty"` // State of the resource, name should be unique.
}

Resource is an immutable representation of the entity producing telemetry.

func (Resource) String

func (r Resource) String() string

func (Resource) TypeName

func (r Resource) TypeName() TypeName

type ResourceMatcher

type ResourceMatcher struct {
	Type     TypeName
	Matchers []*labels.Matcher `json:",omitempty" yaml:",omitempty"`
}

type ResourceQuery

type ResourceQuery struct {
	Time      promModel.Time
	Selectors []*ResourceSelector `json:",omitempty" yaml:",omitempty"`
}

ResourceQuery is the instant query Params

type ResourceQueryRange

type ResourceQueryRange struct {
	Start     promModel.Time
	End       promModel.Time
	Selectors []*ResourceSelector `json:",omitempty" yaml:",omitempty"`
}

type ResourceQueryRangeResponse

type ResourceQueryRangeResponse struct {
	Resources map[TypeName][]HistoricalResource `json:",omitempty" yaml:",omitempty"`
	Relations map[TypeName][]HistoricalRelation `json:",omitempty" yaml:",omitempty"`
}

type ResourceQueryResponse

type ResourceQueryResponse struct {
	Resources map[TypeName][]Resource `json:",omitempty" yaml:",omitempty"`
	Relations map[TypeName][]Relation `json:",omitempty" yaml:",omitempty"`
}

type ResourceSchema

type ResourceSchema struct {
	Name        TypeName
	Brief       string
	Prefix      string
	UrnPattern  string // UrnPattern is a NamedRegex that can be used transform urn from attributes.
	ShowPattern string // ShowPattern is a short name pattern for represent
	Attributes  []*AttributeSchema
}

type ResourceSelector

type ResourceSelector struct {
	// SourceMatcher Start point of resource searching, required.
	SourceMatcher *ResourceMatcher `json:",omitempty" yaml:",omitempty"`
	// TargetMatcher Endpoint of resource searching, required.
	TargetMatcher *ResourceMatcher `json:",omitempty" yaml:",omitempty"`
	// ShowState return the resource with global state.
	ShowState bool
	// Relations return more resources that match the relation of Matcher, optional.
	Relations []*RelationName `json:",omitempty" yaml:",omitempty"`
}

type State

type State struct {
	Name        promModel.LabelName // The name of the state, must be unique in the resource level and cannot be null or empty.
	StateRecord `json:",inline" yaml:",inline"`
}

State is a Key-value struct for describe a status of the resource in some aspect. The value is enum value.

type StateQuery

type StateQuery struct {
	Time      promModel.Time
	Selectors []*StateSelector
}

StateQuery is the instant query Params

type StateQueryRange

type StateQueryRange struct {
	Start   promModel.Time
	End     promModel.Time
	Matcher ResourceMatcher

	// States selector of stateName
	States labels.Matcher
}

type StateQueryRangeResponse

type StateQueryRangeResponse struct {
	Content map[string][]*HistoricalState
}

type StateQueryResponse

type StateQueryResponse struct {
	Content map[string][]*State
}

type StateRecord

type StateRecord struct {
	Since promModel.Time `json:",omitempty"` // The time of state value change to.
	EndUp promModel.Time `json:",omitempty"` // The time of state value change to.
	Value StateValue     // The value of the state, must be match StateValue.
}

type StateSelector

type StateSelector struct {
	// Matcher Start point of resource searching, required.
	Matcher ResourceMatcher

	// States selector of stateName
	States labels.Matcher
}

type StateValue

type StateValue int
const (
	NORMAL StateValue = iota << 2
	INFO
	WARN
	ERROR
	CRITICAL
)

type StringRecord

type StringRecord struct {
	Since promModel.Time       `json:",omitempty"` // The time of the value change to.
	EndUp promModel.Time       `json:",omitempty"` // The time of relation finished.
	Value promModel.LabelValue // The value, cannot be null or empty.
}

type TypeName

type TypeName string

A TypeName is a key for a Resource Schema. It has a value associated therewith.

func (TypeName) IsValid

func (tn TypeName) IsValid() bool

IsValid is true iff the label name matches the pattern of SchemaNameRE. This method, however, does not use SchemaNameRE for the check but a much faster hardcoded implementation.

func (*TypeName) UnmarshalJSON

func (tn *TypeName) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*TypeName) UnmarshalYAML

func (tn *TypeName) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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