Documentation ¶
Index ¶
- func IsDefaultPolicies(ps []Policy) bool
- type ByResolutionAscRetentionDesc
- type ByRetentionAscResolutionAsc
- type DropPolicy
- type Policies
- type PoliciesList
- type PoliciesPool
- type Policy
- type Resolution
- type ResolutionValue
- type Retention
- type RetentionValue
- type StagedPolicies
- func (p StagedPolicies) Equals(other StagedPolicies) bool
- func (p StagedPolicies) IsDefault() bool
- func (p StagedPolicies) MarshalJSON() ([]byte, error)
- func (p StagedPolicies) Policies() ([]Policy, bool)
- func (p *StagedPolicies) Reset()
- func (p StagedPolicies) String() string
- func (p *StagedPolicies) UnmarshalJSON(data []byte) error
- type StoragePolicies
- type StoragePolicy
- func (p *StoragePolicy) FromProto(pb policypb.StoragePolicy) error
- func (p StoragePolicy) MarshalJSON() ([]byte, error)
- func (p StoragePolicy) Proto() (*policypb.StoragePolicy, error)
- func (p StoragePolicy) Resolution() Resolution
- func (p StoragePolicy) Retention() Retention
- func (p StoragePolicy) String() string
- func (p StoragePolicy) ToProto(pb *policypb.StoragePolicy) error
- func (p *StoragePolicy) UnmarshalJSON(data []byte) error
- func (p *StoragePolicy) UnmarshalYAML(unmarshal func(interface{}) error) error
- type VersionedPoliciesList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDefaultPolicies ¶
IsDefaultPolicies checks if the policies are the default policies.
Types ¶
type ByResolutionAscRetentionDesc ¶
type ByResolutionAscRetentionDesc StoragePolicies
ByResolutionAscRetentionDesc implements the sort.Sort interface that enables sorting storage policies by resolution in ascending order and then by retention in descending order.
func (ByResolutionAscRetentionDesc) Len ¶
func (sp ByResolutionAscRetentionDesc) Len() int
func (ByResolutionAscRetentionDesc) Less ¶
func (sp ByResolutionAscRetentionDesc) Less(i, j int) bool
func (ByResolutionAscRetentionDesc) Swap ¶
func (sp ByResolutionAscRetentionDesc) Swap(i, j int)
type ByRetentionAscResolutionAsc ¶ added in v0.7.3
type ByRetentionAscResolutionAsc StoragePolicies
ByRetentionAscResolutionAsc implements the sort.Sort interface that enables sorting storage policies by retention in ascending order and then by resolution in ascending order.
func (ByRetentionAscResolutionAsc) Len ¶ added in v0.7.3
func (sp ByRetentionAscResolutionAsc) Len() int
func (ByRetentionAscResolutionAsc) Less ¶ added in v0.7.3
func (sp ByRetentionAscResolutionAsc) Less(i, j int) bool
func (ByRetentionAscResolutionAsc) Swap ¶ added in v0.7.3
func (sp ByRetentionAscResolutionAsc) Swap(i, j int)
type DropPolicy ¶
type DropPolicy uint
DropPolicy is a metrics dropping policy.
const ( // DropNone specifies not to drop any of the matched metrics. DropNone DropPolicy = iota // DropMust specifies to always drop matched metrics, irregardless of // other rules. DropMust // DropIfOnlyMatch specifies to drop matched metrics, but only if no // other rules match. DropIfOnlyMatch // DefaultDropPolicy is to drop none. DefaultDropPolicy = DropNone )
NB(r): The enum values are an exact match with protobuf values so they can be casted to each other.
func ParseDropPolicy ¶
func ParseDropPolicy(str string) (DropPolicy, error)
ParseDropPolicy parses a drop policy.
func ValidDropPolicies ¶
func ValidDropPolicies() []DropPolicy
ValidDropPolicies returns a copy of all the valid drop policies.
func (DropPolicy) IsDefault ¶
func (p DropPolicy) IsDefault() bool
IsDefault returns whether the drop policy is the default drop none policy.
func (DropPolicy) IsValid ¶
func (p DropPolicy) IsValid() bool
IsValid returns whether a drop policy value is a known valid value.
func (DropPolicy) String ¶
func (p DropPolicy) String() string
func (*DropPolicy) UnmarshalYAML ¶
func (p *DropPolicy) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshals a drop policy value from a string.
type Policies ¶
type Policies []Policy
Policies is a list of policies. Used to check ploicy list equivalence.
type PoliciesList ¶
type PoliciesList []StagedPolicies
PoliciesList is a list of staged policies.
func (PoliciesList) IsDefault ¶
func (l PoliciesList) IsDefault() bool
IsDefault determines whether this is a default policies list.
type PoliciesPool ¶
type PoliciesPool interface { // Init initializes the pool. Init() // Get provides a policy slice from the pool. Get(capacity int) []Policy // Put returns a policy slice to the pool. Put(value []Policy) }
PoliciesPool provides a pool for variable-sized policy slices.
func NewPoliciesPool ¶
func NewPoliciesPool(sizes []pool.Bucket, opts pool.ObjectPoolOptions) PoliciesPool
NewPoliciesPool creates a new policies pool.
type Policy ¶
type Policy struct { StoragePolicy AggregationID aggregation.ID }
Policy contains a storage policy and a list of custom aggregation types.
var ( // DefaultPolicy represents a default policy. DefaultPolicy Policy )
func NewPoliciesFromProto ¶
NewPoliciesFromProto creates multiple new policies from given proto policies.
func NewPolicy ¶
func NewPolicy(sp StoragePolicy, aggID aggregation.ID) Policy
NewPolicy creates a policy.
func NewPolicyFromProto ¶
NewPolicyFromProto creates a new policy from a proto policy.
func ParsePolicy ¶
ParsePolicy parses a policy in the form of resolution:retention|aggregationTypes.
func (Policy) MarshalJSON ¶
MarshalJSON returns the JSON encoding of a policy.
func (*Policy) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON-encoded data into a policy.
func (*Policy) UnmarshalYAML ¶
UnmarshalYAML unmarshals a policy value from a string.
type Resolution ¶
type Resolution struct { // Window is the bucket size represented by the resolution. Window time.Duration // Precision is the precision of datapoints stored at this resoluion. Precision xtime.Unit }
Resolution is the sampling resolution for datapoints.
var ( // EmptyResolution is an empty resolution. EmptyResolution Resolution )
func MustParseResolution ¶
func MustParseResolution(str string) Resolution
MustParseResolution parses a resolution in the form of window@precision, and panics if the input string is invalid.
func ParseResolution ¶
func ParseResolution(str string) (Resolution, error)
ParseResolution parses a resolution.
func (*Resolution) FromProto ¶
func (r *Resolution) FromProto(pb *policypb.Resolution) error
FromProto converts the protobuf message to a resolution in place.
func (Resolution) String ¶
func (r Resolution) String() string
String is the string representation of a resolution.
func (Resolution) ToProto ¶
func (r Resolution) ToProto(pb *policypb.Resolution) error
ToProto converts the resolution to a protobuf message in place.
type ResolutionValue ¶
type ResolutionValue int
ResolutionValue is the resolution value.
const ( UnknownResolutionValue ResolutionValue = iota OneSecond TenSeconds OneMinute FiveMinutes TenMinutes )
List of known resolution values.
func ValueFromResolution ¶
func ValueFromResolution(resolution Resolution) (ResolutionValue, error)
ValueFromResolution returns the value given a resolution.
func (ResolutionValue) IsValid ¶
func (v ResolutionValue) IsValid() bool
IsValid returns whether the resolution value is valid.
func (ResolutionValue) Resolution ¶
func (v ResolutionValue) Resolution() (Resolution, error)
Resolution returns the resolution associated with a value.
type Retention ¶
Retention is the retention period for datapoints.
var ( // EmptyRetention is an empty retention. EmptyRetention Retention )
func MustParseRetention ¶
MustParseRetention parses a retention, and panics if the input is invalid.
func ParseRetention ¶
ParseRetention parses a retention.
type RetentionValue ¶
type RetentionValue int
RetentionValue is the retention value.
const ( UnknownRetentionValue RetentionValue = iota OneHour SixHours TwelveHours OneDay TwoDays SevenDays FourteenDays ThirtyDays FourtyFiveDays )
List of known retention values.
func ValueFromRetention ¶
func ValueFromRetention(retention Retention) (RetentionValue, error)
ValueFromRetention returns the value given a retention.
func (RetentionValue) IsValid ¶
func (v RetentionValue) IsValid() bool
IsValid returns whether the retention value is valid.
func (RetentionValue) Retention ¶
func (v RetentionValue) Retention() (Retention, error)
Retention returns the retention associated with a value.
type StagedPolicies ¶
type StagedPolicies struct { // Cutover is when the policies take effect. CutoverNanos int64 // Tombstoned determines whether the associated (rollup) metric has been tombstoned. Tombstoned bool // contains filtered or unexported fields }
StagedPolicies represent a list of policies at a specified version.
var ( // DefaultStagedPolicies represents a default staged policies. DefaultStagedPolicies StagedPolicies // DefaultPoliciesList represents a default policies list. DefaultPoliciesList = PoliciesList{DefaultStagedPolicies} )
func NewStagedPolicies ¶
func NewStagedPolicies(cutoverNanos int64, tombstoned bool, policies []Policy) StagedPolicies
NewStagedPolicies create a new staged policies.
func (StagedPolicies) Equals ¶
func (p StagedPolicies) Equals(other StagedPolicies) bool
Equals returns whether two staged policies are equal.
func (StagedPolicies) IsDefault ¶
func (p StagedPolicies) IsDefault() bool
IsDefault returns whether this is a default staged policies.
func (StagedPolicies) MarshalJSON ¶
func (p StagedPolicies) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of staged policies.
func (StagedPolicies) Policies ¶
func (p StagedPolicies) Policies() ([]Policy, bool)
Policies returns the policies and whether the policies are the default policies.
func (StagedPolicies) String ¶
func (p StagedPolicies) String() string
String is the representation of staged policies.
func (*StagedPolicies) UnmarshalJSON ¶
func (p *StagedPolicies) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON-encoded data into staged policies.
type StoragePolicies ¶
type StoragePolicies []StoragePolicy
StoragePolicies is a list of storage policies.
func NewStoragePoliciesFromProto ¶
func NewStoragePoliciesFromProto( storagePolicies []*policypb.StoragePolicy, ) (StoragePolicies, error)
NewStoragePoliciesFromProto creates a list of storage policies from given storage policies proto.
func (StoragePolicies) Clone ¶
func (sp StoragePolicies) Clone() StoragePolicies
Clone clones the list of storage policies.
func (StoragePolicies) Equal ¶
func (sp StoragePolicies) Equal(other StoragePolicies) bool
Equal returns true if two lists of storage policies are considered equal.
func (StoragePolicies) IsDefault ¶
func (sp StoragePolicies) IsDefault() bool
IsDefault returns whether a list of storage policies are considered as default storage policies.
func (StoragePolicies) Proto ¶
func (sp StoragePolicies) Proto() ([]*policypb.StoragePolicy, error)
Proto returns the proto message for the given list of storage policies.
type StoragePolicy ¶
type StoragePolicy struct {
// contains filtered or unexported fields
}
StoragePolicy represents the resolution and retention period metric datapoints are stored at.
var ( // EmptyStoragePolicy represents an empty storage policy. EmptyStoragePolicy StoragePolicy )
func MustParseStoragePolicy ¶
func MustParseStoragePolicy(str string) StoragePolicy
MustParseStoragePolicy parses a storage policy in the form of resolution:retention, and panics if the input string is invalid.
func NewStoragePolicy ¶
func NewStoragePolicy(window time.Duration, precision xtime.Unit, retention time.Duration) StoragePolicy
NewStoragePolicy creates a new storage policy given a resolution and a retention.
func NewStoragePolicyFromProto ¶
func NewStoragePolicyFromProto(pb *policypb.StoragePolicy) (StoragePolicy, error)
NewStoragePolicyFromProto creates a new storage policy from a storage policy protobuf message.
func ParseStoragePolicy ¶
func ParseStoragePolicy(str string) (StoragePolicy, error)
ParseStoragePolicy parses a storage policy in the form of resolution:retention.
func (*StoragePolicy) FromProto ¶
func (p *StoragePolicy) FromProto(pb policypb.StoragePolicy) error
FromProto converts the protobuf message to a storage policy in place.
func (StoragePolicy) MarshalJSON ¶
func (p StoragePolicy) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of a storage policy.
func (StoragePolicy) Proto ¶
func (p StoragePolicy) Proto() (*policypb.StoragePolicy, error)
Proto returns the proto message for the storage policy.
func (StoragePolicy) Resolution ¶
func (p StoragePolicy) Resolution() Resolution
Resolution returns the resolution of the storage policy.
func (StoragePolicy) Retention ¶
func (p StoragePolicy) Retention() Retention
Retention return the retention of the storage policy.
func (StoragePolicy) String ¶
func (p StoragePolicy) String() string
String is the string representation of a storage policy.
func (StoragePolicy) ToProto ¶
func (p StoragePolicy) ToProto(pb *policypb.StoragePolicy) error
ToProto converts the storage policy to a protobuf message in place.
func (*StoragePolicy) UnmarshalJSON ¶
func (p *StoragePolicy) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON-encoded data into a storage policy.
func (*StoragePolicy) UnmarshalYAML ¶
func (p *StoragePolicy) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshals a storage policy value from a string.
type VersionedPoliciesList ¶
type VersionedPoliciesList struct { // Version is the version associcated with the policies in the list. Version int `json:"version"` // PoliciesList contains the list of staged policies. PoliciesList PoliciesList `json:"policiesList"` }
VersionedPoliciesList is a versioned policies list.