Documentation ¶
Overview ¶
Package rules is a generated GoMock package.
Index ¶
- Variables
- type IDWithMetadatas
- type IDWithMetadatasByIDAsc
- type MatchResult
- func (r *MatchResult) ExpireAtNanos() int64
- func (r *MatchResult) ForExistingIDAt(timeNanos int64) metadata.StagedMetadatas
- func (r *MatchResult) ForNewRollupIDsAt(idx int, timeNanos int64) IDWithMetadatas
- func (r *MatchResult) HasExpired(timeNanos int64) bool
- func (r *MatchResult) KeepOriginal() bool
- func (r *MatchResult) NumNewRollupIDs() int
- func (r *MatchResult) Version() int
- type Matcher
- type MockStore
- func (m *MockStore) Close()
- func (m *MockStore) EXPECT() *MockStoreMockRecorder
- func (m *MockStore) ReadNamespaces() (*Namespaces, error)
- func (m *MockStore) ReadRuleSet(arg0 string) (RuleSet, error)
- func (m *MockStore) WriteAll(arg0 *Namespaces, arg1 MutableRuleSet) error
- func (m *MockStore) WriteNamespaces(arg0 *Namespaces) error
- func (m *MockStore) WriteRuleSet(arg0 MutableRuleSet) error
- type MockStoreMockRecorder
- func (mr *MockStoreMockRecorder) Close() *gomock.Call
- func (mr *MockStoreMockRecorder) ReadNamespaces() *gomock.Call
- func (mr *MockStoreMockRecorder) ReadRuleSet(arg0 interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) WriteAll(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) WriteNamespaces(arg0 interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) WriteRuleSet(arg0 interface{}) *gomock.Call
- type MutableRuleSet
- type Namespace
- type NamespaceSnapshot
- type Namespaces
- func (nss *Namespaces) AddNamespace(nsName string, meta UpdateMetadata) (bool, error)
- func (nss Namespaces) Clone() Namespaces
- func (nss *Namespaces) DeleteNamespace(nsName string, currRuleSetVersion int, meta UpdateMetadata) error
- func (nss *Namespaces) Namespace(name string) (*Namespace, error)
- func (nss Namespaces) Namespaces() []Namespace
- func (nss Namespaces) NamespacesView() (view.Namespaces, error)
- func (nss Namespaces) Proto() (*rulepb.Namespaces, error)
- func (nss Namespaces) Version() int
- type Options
- type RuleSet
- type RuleSetUpdateHelper
- type Store
- type UpdateMetadata
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( // EmptyMatchResult is the result when no matches were found. EmptyMatchResult = NewMatchResult( kv.UninitializedVersion, timeNanosMax, metadata.DefaultStagedMetadatas, nil, false, ) )
Functions ¶
This section is empty.
Types ¶
type IDWithMetadatas ¶
type IDWithMetadatas struct { ID []byte Metadatas metadata.StagedMetadatas }
IDWithMetadatas is a pair of metric ID and the associated staged metadatas.
type IDWithMetadatasByIDAsc ¶
type IDWithMetadatasByIDAsc []IDWithMetadatas
IDWithMetadatasByIDAsc sorts a list of ID with metadatas by metric ID in ascending order.
func (IDWithMetadatasByIDAsc) Len ¶
func (a IDWithMetadatasByIDAsc) Len() int
func (IDWithMetadatasByIDAsc) Less ¶
func (a IDWithMetadatasByIDAsc) Less(i, j int) bool
func (IDWithMetadatasByIDAsc) Swap ¶
func (a IDWithMetadatasByIDAsc) Swap(i, j int)
type MatchResult ¶
type MatchResult struct {
// contains filtered or unexported fields
}
MatchResult represents a match result.
func NewMatchResult ¶
func NewMatchResult( version int, expireAtNanos int64, forExistingID metadata.StagedMetadatas, forNewRollupIDs []IDWithMetadatas, keepOriginal bool, ) MatchResult
NewMatchResult creates a new match result.
func (*MatchResult) ExpireAtNanos ¶
func (r *MatchResult) ExpireAtNanos() int64
ExpireAtNanos returns the expiration time of the match result in nanoseconds.
func (*MatchResult) ForExistingIDAt ¶
func (r *MatchResult) ForExistingIDAt(timeNanos int64) metadata.StagedMetadatas
ForExistingIDAt returns the staged metadatas for existing ID at a given time.
func (*MatchResult) ForNewRollupIDsAt ¶
func (r *MatchResult) ForNewRollupIDsAt(idx int, timeNanos int64) IDWithMetadatas
ForNewRollupIDsAt returns the the new rollup ID alongside its staged metadatas for a given index at a given time.
func (*MatchResult) HasExpired ¶
func (r *MatchResult) HasExpired(timeNanos int64) bool
HasExpired returns whether the match result has expired for a given time.
func (*MatchResult) KeepOriginal ¶ added in v1.0.0
func (r *MatchResult) KeepOriginal() bool
KeepOriginal returns true if the original source metric for a rollup rule should be kept, and false if it should be dropped.
func (*MatchResult) NumNewRollupIDs ¶
func (r *MatchResult) NumNewRollupIDs() int
NumNewRollupIDs returns the number of new rollup metric IDs generated as a result of rule matching.
func (*MatchResult) Version ¶
func (r *MatchResult) Version() int
Version returns the version of the match result.
type Matcher ¶
type Matcher interface { // ForwardMatch matches the applicable policies for a metric id between [fromNanos, toNanos). ForwardMatch(id []byte, fromNanos, toNanos int64) MatchResult // ReverseMatch reverse matches the applicable policies for a metric id between [fromNanos, toNanos), // with aware of the metric type and aggregation type for the given id. ReverseMatch( id []byte, fromNanos, toNanos int64, mt metric.Type, at aggregation.Type, isMultiAggregationTypesAllowed bool, aggTypesOpts aggregation.TypesOptions, ) MatchResult }
Matcher matches metrics against rules to determine applicable policies.
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore is a mock of Store interface.
func NewMockStore ¶
func NewMockStore(ctrl *gomock.Controller) *MockStore
NewMockStore creates a new mock instance.
func (*MockStore) EXPECT ¶
func (m *MockStore) EXPECT() *MockStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStore) ReadNamespaces ¶
func (m *MockStore) ReadNamespaces() (*Namespaces, error)
ReadNamespaces mocks base method.
func (*MockStore) ReadRuleSet ¶
ReadRuleSet mocks base method.
func (*MockStore) WriteAll ¶
func (m *MockStore) WriteAll(arg0 *Namespaces, arg1 MutableRuleSet) error
WriteAll mocks base method.
func (*MockStore) WriteNamespaces ¶ added in v1.0.1
func (m *MockStore) WriteNamespaces(arg0 *Namespaces) error
WriteNamespaces mocks base method.
func (*MockStore) WriteRuleSet ¶
func (m *MockStore) WriteRuleSet(arg0 MutableRuleSet) error
WriteRuleSet mocks base method.
type MockStoreMockRecorder ¶
type MockStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockStoreMockRecorder is the mock recorder for MockStore.
func (*MockStoreMockRecorder) Close ¶
func (mr *MockStoreMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockStoreMockRecorder) ReadNamespaces ¶
func (mr *MockStoreMockRecorder) ReadNamespaces() *gomock.Call
ReadNamespaces indicates an expected call of ReadNamespaces.
func (*MockStoreMockRecorder) ReadRuleSet ¶
func (mr *MockStoreMockRecorder) ReadRuleSet(arg0 interface{}) *gomock.Call
ReadRuleSet indicates an expected call of ReadRuleSet.
func (*MockStoreMockRecorder) WriteAll ¶
func (mr *MockStoreMockRecorder) WriteAll(arg0, arg1 interface{}) *gomock.Call
WriteAll indicates an expected call of WriteAll.
func (*MockStoreMockRecorder) WriteNamespaces ¶ added in v1.0.1
func (mr *MockStoreMockRecorder) WriteNamespaces(arg0 interface{}) *gomock.Call
WriteNamespaces indicates an expected call of WriteNamespaces.
func (*MockStoreMockRecorder) WriteRuleSet ¶
func (mr *MockStoreMockRecorder) WriteRuleSet(arg0 interface{}) *gomock.Call
WriteRuleSet indicates an expected call of WriteRuleSet.
type MutableRuleSet ¶
type MutableRuleSet interface { RuleSet // Clone returns a copy of this MutableRuleSet. Clone() MutableRuleSet // AppendMappingRule creates a new mapping rule and adds it to this ruleset. // Should return the id of the newly created rule. AddMappingRule(view.MappingRule, UpdateMetadata) (string, error) // UpdateMappingRule creates a new mapping rule and adds it to this ruleset. UpdateMappingRule(view.MappingRule, UpdateMetadata) error // DeleteMappingRule deletes a mapping rule DeleteMappingRule(string, UpdateMetadata) error // AppendRollupRule creates a new rollup rule and adds it to this ruleset. // Should return the id of the newly created rule. AddRollupRule(view.RollupRule, UpdateMetadata) (string, error) // UpdateRollupRule creates a new rollup rule and adds it to this ruleset. UpdateRollupRule(view.RollupRule, UpdateMetadata) error // DeleteRollupRule deletes a rollup rule DeleteRollupRule(string, UpdateMetadata) error // Tombstone tombstones this ruleset and all of its rules. Delete(UpdateMetadata) error // Revive removes the tombstone from this ruleset. It does not revive any rules. Revive(UpdateMetadata) error // ApplyRuleSetChanges takes set of rule set changes and applies them to a ruleset. ApplyRuleSetChanges(changes.RuleSetChanges, UpdateMetadata) error }
MutableRuleSet is mutable ruleset.
func NewEmptyRuleSet ¶
func NewEmptyRuleSet(namespaceName string, meta UpdateMetadata) MutableRuleSet
NewEmptyRuleSet returns an empty ruleset to be used with a new namespace.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace stores namespace snapshots.
func (Namespace) NamespaceView ¶
NamespaceView returns the view representation of a namespace object.
func (Namespace) Snapshots ¶
func (n Namespace) Snapshots() []NamespaceSnapshot
Snapshots return the namespace snapshots.
func (Namespace) Tombstoned ¶
Tombstoned returns the tombstoned state for a given namespace.
type NamespaceSnapshot ¶
type NamespaceSnapshot struct {
// contains filtered or unexported fields
}
NamespaceSnapshot defines a namespace snapshot for which rules are defined.
func (NamespaceSnapshot) ForRuleSetVersion ¶
func (s NamespaceSnapshot) ForRuleSetVersion() int
ForRuleSetVersion is the ruleset version this namespace change is related to.
func (NamespaceSnapshot) LastUpdatedAtNanos ¶
func (s NamespaceSnapshot) LastUpdatedAtNanos() int64
LastUpdatedAtNanos returns the time when the namespace is last updated in nanoseconds.
func (NamespaceSnapshot) LastUpdatedBy ¶
func (s NamespaceSnapshot) LastUpdatedBy() string
LastUpdatedBy returns the user who last updated the namespace.
func (NamespaceSnapshot) Proto ¶
func (s NamespaceSnapshot) Proto() *rulepb.NamespaceSnapshot
Proto returns the given Namespace in protobuf form
func (NamespaceSnapshot) Tombstoned ¶
func (s NamespaceSnapshot) Tombstoned() bool
Tombstoned determines whether the namespace has been tombstoned.
type Namespaces ¶
type Namespaces struct {
// contains filtered or unexported fields
}
Namespaces store the list of namespaces for which rules are defined.
func NewNamespaces ¶
func NewNamespaces(version int, namespaces *rulepb.Namespaces) (Namespaces, error)
NewNamespaces creates new namespaces.
func (*Namespaces) AddNamespace ¶
func (nss *Namespaces) AddNamespace(nsName string, meta UpdateMetadata) (bool, error)
AddNamespace adds a new namespace to the namespaces structure and persists it. This function returns a boolean indicating whether or not the namespace was revived. The revived flag should be used to decided if the corresponding" ruleset should also be revived.
func (Namespaces) Clone ¶
func (nss Namespaces) Clone() Namespaces
Clone creates a deep copy of this Namespaces object.
func (*Namespaces) DeleteNamespace ¶
func (nss *Namespaces) DeleteNamespace(nsName string, currRuleSetVersion int, meta UpdateMetadata) error
DeleteNamespace tombstones the given namespace mapping it to the next ruleset version.
func (*Namespaces) Namespace ¶
func (nss *Namespaces) Namespace(name string) (*Namespace, error)
Namespace returns a namespace with a given name.
func (Namespaces) Namespaces ¶
func (nss Namespaces) Namespaces() []Namespace
Namespaces returns the list of namespaces.
func (Namespaces) NamespacesView ¶
func (nss Namespaces) NamespacesView() (view.Namespaces, error)
NamespacesView returns a view representation of a given Namespaces object.
func (Namespaces) Proto ¶
func (nss Namespaces) Proto() (*rulepb.Namespaces, error)
Proto returns the given Namespaces slice in protobuf form.
func (Namespaces) Version ¶
func (nss Namespaces) Version() int
Version returns the namespaces version.
type Options ¶
type Options interface { // SetTagsFilterOptions sets the tags filter options. SetTagsFilterOptions(value filters.TagsFilterOptions) Options // TagsFilterOptions returns the tags filter options. TagsFilterOptions() filters.TagsFilterOptions // SetNewRollupIDFn sets the new rollup id function. SetNewRollupIDFn(value id.NewIDFn) Options // NewRollupIDFn returns the new rollup id function. NewRollupIDFn() id.NewIDFn // SetIsRollupIDFn sets the function that determines whether an id is a rollup id. SetIsRollupIDFn(value id.MatchIDFn) Options // IsRollupIDFn returns the function that determines whether an id is a rollup id. IsRollupIDFn() id.MatchIDFn }
Options provide a set of options for rule matching.
type RuleSet ¶
type RuleSet interface { // Namespace is the metrics namespace the ruleset applies to. Namespace() []byte // Version returns the ruleset version. Version() int // CutoverNanos returns when the ruleset takes effect. CutoverNanos() int64 // TombStoned returns whether the ruleset is tombstoned. Tombstoned() bool // CreatedAtNanos returns the creation time for this ruleset. CreatedAtNanos() int64 // LastUpdatedAtNanos returns the time when this ruleset was last updated. LastUpdatedAtNanos() int64 // Proto returns the rulepb.Ruleset representation of this ruleset. Proto() (*rulepb.RuleSet, error) // MappingRuleHistory returns a map of mapping rule id to states that rule has been in. MappingRules() (view.MappingRules, error) // RollupRuleHistory returns a map of rollup rule id to states that rule has been in. RollupRules() (view.RollupRules, error) // Latest returns the latest snapshot of a ruleset containing the latest snapshots // of each rule in the ruleset. Latest() (view.RuleSet, error) // ActiveSet returns the active ruleset at a given time. ActiveSet(timeNanos int64) Matcher // ToMutableRuleSet returns a mutable version of this ruleset. ToMutableRuleSet() MutableRuleSet }
RuleSet is a read-only set of rules associated with a namespace.
type RuleSetUpdateHelper ¶
type RuleSetUpdateHelper struct {
// contains filtered or unexported fields
}
RuleSetUpdateHelper stores the necessary details to create an UpdateMetadata.
func NewRuleSetUpdateHelper ¶
func NewRuleSetUpdateHelper(propagationDelay time.Duration) RuleSetUpdateHelper
NewRuleSetUpdateHelper creates a new RuleSetUpdateHelper struct.
func (RuleSetUpdateHelper) NewUpdateMetadata ¶
func (r RuleSetUpdateHelper) NewUpdateMetadata(updateTime int64, updatedBy string) UpdateMetadata
NewUpdateMetadata creates a properly initialized UpdateMetadata object.
type Store ¶
type Store interface { // ReadNamespaces returns the persisted namespaces in kv store. ReadNamespaces() (*Namespaces, error) // ReadRuleSet returns the persisted ruleset in kv store. ReadRuleSet(nsName string) (RuleSet, error) // WriteRuleSet saves the given ruleset to the backing store. WriteRuleSet(rs MutableRuleSet) error // WriteNamespaces saves the given namespaces to the backing store. WriteNamespaces(nss *Namespaces) error // WriteAll saves both the given ruleset and namespace to the backing store. WriteAll(nss *Namespaces, rs MutableRuleSet) error // Close closes the store. Close() }
Store performs read/write operations for rules and namespaces.
type UpdateMetadata ¶
type UpdateMetadata struct {
// contains filtered or unexported fields
}
UpdateMetadata contains descriptive information that needs to be updated with any modification of the ruleset.