policy

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefaultPolicies

func IsDefaultPolicies(ps []Policy) bool

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 (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 (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) MarshalText added in v0.12.0

func (p DropPolicy) MarshalText() ([]byte, error)

MarshalText marshals a drop policy to a string.

func (DropPolicy) String

func (p DropPolicy) String() string

func (*DropPolicy) UnmarshalText added in v0.12.0

func (p *DropPolicy) UnmarshalText(data []byte) error

UnmarshalText unmarshals a drop policy value from a string. Empty string defaults to DefaultDropPolicy.

type Policies

type Policies []Policy

Policies is a list of policies. Used to check ploicy list equivalence.

func (Policies) Equals

func (p Policies) Equals(other Policies) bool

Equals takes a list of policies and checks 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

func NewPoliciesFromProto(policies []*policypb.Policy) ([]Policy, error)

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

func NewPolicyFromProto(p *policypb.Policy) (Policy, error)

NewPolicyFromProto creates a new policy from a proto policy.

func ParsePolicy

func ParsePolicy(str string) (Policy, error)

ParsePolicy parses a policy in the form of resolution:retention|aggregationTypes.

func (Policy) MarshalText added in v0.12.0

func (p Policy) MarshalText() ([]byte, error)

MarshalText returns the text encoding of a policy.

func (Policy) Proto

func (p Policy) Proto() (*policypb.Policy, error)

Proto returns the proto of the policy.

func (Policy) String

func (p Policy) String() string

String is the string representation of a policy.

func (*Policy) UnmarshalText added in v0.12.0

func (p *Policy) UnmarshalText(data []byte) error

UnmarshalText unmarshals text-encoded data into a policy.

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

type Retention time.Duration

Retention is the retention period for datapoints.

var (

	// EmptyRetention is an empty retention.
	EmptyRetention Retention
)

func MustParseRetention

func MustParseRetention(str string) Retention

MustParseRetention parses a retention, and panics if the input is invalid.

func ParseRetention

func ParseRetention(str string) (Retention, error)

ParseRetention parses a retention.

func (Retention) Duration

func (r Retention) Duration() time.Duration

Duration returns the duration of the retention period.

func (*Retention) FromProto

func (r *Retention) FromProto(pb *policypb.Retention) error

FromProto converts the protobuf message to a retention in place.

func (Retention) String

func (r Retention) String() string

String is the string representation of a retention period.

func (Retention) ToProto

func (r Retention) ToProto(pb *policypb.Retention)

ToProto converts the retention to a protobuf message in place.

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) Reset

func (p *StagedPolicies) Reset()

Reset resets the staged 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) Equivalent added in v0.15.0

func (p StoragePolicy) Equivalent(other StoragePolicy) bool

Equivalent returns whether two storage policies are equal by their retention width and resolution. The resolution precision is ignored for equivalency (hence why the method is not named Equal).

func (*StoragePolicy) FromProto

func (p *StoragePolicy) FromProto(pb policypb.StoragePolicy) error

FromProto converts the protobuf message to a storage policy in place.

func (StoragePolicy) MarshalText added in v0.12.0

func (p StoragePolicy) MarshalText() ([]byte, error)

MarshalText returns the text 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) UnmarshalText added in v0.12.0

func (p *StoragePolicy) UnmarshalText(data []byte) error

UnmarshalText unmarshals text-encoded data into a storage policy.

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.

Jump to

Keyboard shortcuts

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