rules

package
v0.0.0-...-4396b16 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TSMReadOnly is a flag for rules that should be read only for TSM files
	TSMReadOnly = 1
	// WALReadOnly is a flag for rules that should be read only for WAL files
	WALReadOnly = TSMReadOnly << 1

	// TSMWriteOnly is a flag for rules that should only write TSM files
	TSMWriteOnly = WALReadOnly << 1
	// WALWriteOnly is a flag for rules that should only write WAL files
	WALWriteOnly = TSMWriteOnly << 1

	// ReadOnly is a flag for rules that should be readonly only
	ReadOnly = TSMReadOnly | WALReadOnly

	// Standard is a flag for standard rules
	Standard = TSMWriteOnly | WALWriteOnly
)

Variables

This section is empty.

Functions

func EnsureValueType

func EnsureValueType(value tsm1.Value, expectedType influxql.DataType) (tsm1.Value, bool, error)

EnsureValueType casts a Value to a given data type

func RegisterRule

func RegisterRule(name string, fn NewRuleFunc)

RegisterRule registers a rule with the given name and config creation callback

Types

type ChainingSet

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

ChainingSet is a set of rules that are applied in chain

func NewChainingSet

func NewChainingSet(rules []Rule) *ChainingSet

NewChainingSet creates a new chaining set

func (*ChainingSet) Rules

func (c *ChainingSet) Rules() []Rule

Rules implement the Set interface

type Config

type Config interface {
	Sample() string

	Build() (Rule, error)
}

Config represents a configuration for a rule

func NewRule

func NewRule(name string) (Config, error)

NewRule creates a new rule configuration based on its registration name

type DropSerieRule

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

DropSerieRule defines a rule to drop series

func NewDropSerieRule

func NewDropSerieRule(dropFilter filter.Filter) *DropSerieRule

NewDropSerieRule creates a new DropSerieRule

func (*DropSerieRule) Apply

func (r *DropSerieRule) Apply(key []byte, values []tsm1.Value) ([]byte, []tsm1.Value, error)

Apply implements Rule interface

func (*DropSerieRule) CheckMode

func (r *DropSerieRule) CheckMode(check bool)

CheckMode sets the check mode on the rule

func (*DropSerieRule) End

func (r *DropSerieRule) End()

End implements Rule interface

func (*DropSerieRule) EndShard

func (r *DropSerieRule) EndShard() error

EndShard implements Rule interface

func (*DropSerieRule) EndTSM

func (r *DropSerieRule) EndTSM()

EndTSM implements Rule interface

func (*DropSerieRule) EndWAL

func (r *DropSerieRule) EndWAL()

EndWAL implements Rule interface

func (*DropSerieRule) Flags

func (r *DropSerieRule) Flags() int

Flags implements Rule interface

func (*DropSerieRule) Start

func (r *DropSerieRule) Start()

Start implements Rule interface

func (*DropSerieRule) StartShard

func (r *DropSerieRule) StartShard(info storage.ShardInfo)

StartShard implements Rule interface

func (*DropSerieRule) StartTSM

func (r *DropSerieRule) StartTSM(path string)

StartTSM implements Rule interface

func (*DropSerieRule) StartWAL

func (r *DropSerieRule) StartWAL(path string)

StartWAL implements Rule interface

func (*DropSerieRule) WithLogger

func (r *DropSerieRule) WithLogger(logger *log.Logger)

WithLogger sets the logger on the rule

type DropSerieRuleConfiguration

type DropSerieRuleConfiguration struct {
	DropFilter filter.Filter
}

DropSerieRuleConfiguration represents the toml configuration for DropSerieRule

func (*DropSerieRuleConfiguration) Build

func (c *DropSerieRuleConfiguration) Build() (Rule, error)

Build implements the Config interface

func (*DropSerieRuleConfiguration) Sample

func (c *DropSerieRuleConfiguration) Sample() string

Sample implements the Config interface

type NewRuleFunc

type NewRuleFunc func() Config

NewRuleFunc represents a callback to register a rule's configuration to be able to load it from toml

type OldSerieRuleConfig

type OldSerieRuleConfig struct {
	Time      string
	Out       string
	Format    string
	Timestamp bool
}

OldSerieRuleConfig represents the toml configuration for OldSerieRule

func (*OldSerieRuleConfig) Build

func (c *OldSerieRuleConfig) Build() (Rule, error)

Build implements Config interface

func (*OldSerieRuleConfig) Sample

func (c *OldSerieRuleConfig) Sample() string

Sample implements Config interface

type OldSeriesRule

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

OldSeriesRule defines a read-only rule to retrieve series that are oldest than a given timestamp

func NewOldSeriesRule

func NewOldSeriesRule(t time.Time, out io.Writer, format string) (*OldSeriesRule, error)

NewOldSeriesRule creates a new OldSeriesRule

func (*OldSeriesRule) Apply

func (r *OldSeriesRule) Apply(key []byte, values []tsm1.Value) ([]byte, []tsm1.Value, error)

Apply implements Rule interface

func (*OldSeriesRule) CheckMode

func (r *OldSeriesRule) CheckMode(check bool)

CheckMode sets the check mode on the rule

func (*OldSeriesRule) End

func (r *OldSeriesRule) End()

End implements Rule interface

func (*OldSeriesRule) EndShard

func (r *OldSeriesRule) EndShard() error

EndShard implements Rule interface

func (*OldSeriesRule) EndTSM

func (r *OldSeriesRule) EndTSM()

EndTSM implements Rule interface

func (*OldSeriesRule) EndWAL

func (r *OldSeriesRule) EndWAL()

EndWAL implements Rule interface

func (*OldSeriesRule) Flags

func (r *OldSeriesRule) Flags() int

Flags implements Rule interface

func (*OldSeriesRule) Print

func (r *OldSeriesRule) Print(iow io.Writer)

Print will print the list of series detected as old

func (*OldSeriesRule) Start

func (r *OldSeriesRule) Start()

Start implements Rule interface

func (*OldSeriesRule) StartShard

func (r *OldSeriesRule) StartShard(info storage.ShardInfo)

StartShard implements Rule interface

func (*OldSeriesRule) StartTSM

func (r *OldSeriesRule) StartTSM(path string)

StartTSM implements Rule interface

func (*OldSeriesRule) StartWAL

func (r *OldSeriesRule) StartWAL(path string)

StartWAL implements Rule interface

func (*OldSeriesRule) WithLogger

func (r *OldSeriesRule) WithLogger(logger *log.Logger)

WithLogger sets the logger on the rule

type RenameFn

type RenameFn func(string) string

RenameFn defines a function to rename a measurement

type RenameMeasurementConfig

type RenameMeasurementConfig struct {
	From string
	To   string
}

RenameMeasurementConfig represents the toml configuration for RenameMeasurementRule

func (*RenameMeasurementConfig) Build

func (c *RenameMeasurementConfig) Build() (Rule, error)

Build implements Config interface

func (*RenameMeasurementConfig) Sample

func (c *RenameMeasurementConfig) Sample() string

Sample implements Config interface

type RenameMeasurementRule

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

RenameMeasurementRule represents a rule to rename a measurement

func NewRenameMeasurement

func NewRenameMeasurement(srcName string, dstName string) *RenameMeasurementRule

NewRenameMeasurement creates a new RenameMeasurementRule to rename a single measurement

func NewRenameMeasurementWithFilter

func NewRenameMeasurementWithFilter(filter filter.Filter, renameFn RenameFn) *RenameMeasurementRule

NewRenameMeasurementWithFilter creates a new RenameMeasurementRule to rename measurements that uses the given filter

func NewRenameMeasurementWithPattern

func NewRenameMeasurementWithPattern(pattern string, renameFn RenameFn) (*RenameMeasurementRule, error)

NewRenameMeasurementWithPattern creates a new RenameMeasurementRule to rename measurements that match the given pattern

func (*RenameMeasurementRule) Apply

func (r *RenameMeasurementRule) Apply(key []byte, values []tsm1.Value) ([]byte, []tsm1.Value, error)

Apply implements Rule interface

func (*RenameMeasurementRule) CheckMode

func (r *RenameMeasurementRule) CheckMode(check bool)

CheckMode sets the check mode on the rule

func (*RenameMeasurementRule) Count

func (r *RenameMeasurementRule) Count() int

Count returns the number of measurements renamed

func (*RenameMeasurementRule) End

func (r *RenameMeasurementRule) End()

End implements Rule interface

func (*RenameMeasurementRule) EndShard

func (r *RenameMeasurementRule) EndShard() error

EndShard implements Rule interface

func (*RenameMeasurementRule) EndTSM

func (r *RenameMeasurementRule) EndTSM()

EndTSM implements Rule interface

func (*RenameMeasurementRule) EndWAL

func (r *RenameMeasurementRule) EndWAL()

EndWAL implements Rule interface

func (*RenameMeasurementRule) Flags

func (r *RenameMeasurementRule) Flags() int

Flags implements Rule interface

func (*RenameMeasurementRule) Start

func (r *RenameMeasurementRule) Start()

Start implements Rule interface

func (*RenameMeasurementRule) StartShard

func (r *RenameMeasurementRule) StartShard(info storage.ShardInfo)

StartShard implements Rule interface

func (*RenameMeasurementRule) StartTSM

func (r *RenameMeasurementRule) StartTSM(path string)

StartTSM implements Rule interface

func (*RenameMeasurementRule) StartWAL

func (r *RenameMeasurementRule) StartWAL(path string)

StartWAL implements Rule interface

func (*RenameMeasurementRule) WithLogger

func (r *RenameMeasurementRule) WithLogger(logger *log.Logger)

WithLogger sets the logger on the rule

type Rule

type Rule interface {
	CheckMode(check bool)
	Flags() int

	Start()
	End()

	StartShard(info storage.ShardInfo)
	EndShard() error

	StartTSM(path string)
	EndTSM()

	StartWAL(path string)
	EndWAL()

	Apply(key []byte, values []tsm1.Value) (newKey []byte, newValues []tsm1.Value, err error)
}

Rule represents a rule to apply to a given TSM or WAL entry

func LoadConfig

func LoadConfig(path string) ([]Rule, error)

LoadConfig will load rules from a TOML configuration file

type Set

type Set interface {
	Rules() []Rule
}

Set defines a set of rules to apply

type UpdateMeasurementFieldTypeRule

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

UpdateMeasurementFieldTypeRule will update a field type for a given measurement

func NewUpdateMeasurementFieldType

func NewUpdateMeasurementFieldType(measurement string, fieldKey string, fromType influxql.DataType, toType influxql.DataType) *UpdateMeasurementFieldTypeRule

NewUpdateMeasurementFieldType creates an UpdateMeasurementFieldTypeRule

func (*UpdateMeasurementFieldTypeRule) Apply

func (r *UpdateMeasurementFieldTypeRule) Apply(key []byte, values []tsm1.Value) ([]byte, []tsm1.Value, error)

Apply implements Rule interface

func (*UpdateMeasurementFieldTypeRule) CheckMode

func (r *UpdateMeasurementFieldTypeRule) CheckMode(check bool)

CheckMode sets the check mode on the rule

func (*UpdateMeasurementFieldTypeRule) End

End implements Rule interface

func (*UpdateMeasurementFieldTypeRule) EndShard

func (r *UpdateMeasurementFieldTypeRule) EndShard() error

EndShard implements Rule interface

func (*UpdateMeasurementFieldTypeRule) EndTSM

func (r *UpdateMeasurementFieldTypeRule) EndTSM()

EndTSM implements Rule interface

func (*UpdateMeasurementFieldTypeRule) EndWAL

func (r *UpdateMeasurementFieldTypeRule) EndWAL()

EndWAL implements Rule interface

func (*UpdateMeasurementFieldTypeRule) Flags

Flags implements Rule interface

func (*UpdateMeasurementFieldTypeRule) Start

func (r *UpdateMeasurementFieldTypeRule) Start()

Start implements Rule interface

func (*UpdateMeasurementFieldTypeRule) StartShard

func (r *UpdateMeasurementFieldTypeRule) StartShard(info storage.ShardInfo)

StartShard implements Rule interface

func (*UpdateMeasurementFieldTypeRule) StartTSM

func (r *UpdateMeasurementFieldTypeRule) StartTSM(path string)

StartTSM implements Rule interface

func (*UpdateMeasurementFieldTypeRule) StartWAL

func (r *UpdateMeasurementFieldTypeRule) StartWAL(path string)

StartWAL implements Rule interface

func (*UpdateMeasurementFieldTypeRule) WithLogger

func (r *UpdateMeasurementFieldTypeRule) WithLogger(logger *log.Logger)

WithLogger sets the logger on the rule

type UpdateTagValueRule

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

UpdateTagValueRule defines a rule to update the value of a tag for a given measurement

func NewUpdateTagValue

func NewUpdateTagValue(measurement string, tagKey string, oldValue string, newValue string) *UpdateTagValueRule

NewUpdateTagValue creates a new UpdateTagValueRule

func (*UpdateTagValueRule) Apply

func (r *UpdateTagValueRule) Apply(key []byte, values []tsm1.Value) ([]byte, []tsm1.Value, error)

Apply implements Rule interface

func (*UpdateTagValueRule) CheckMode

func (r *UpdateTagValueRule) CheckMode(check bool)

CheckMode sets the check mode on the rule

func (*UpdateTagValueRule) End

func (r *UpdateTagValueRule) End()

End implements Rule interface

func (*UpdateTagValueRule) EndShard

func (r *UpdateTagValueRule) EndShard() error

EndShard implements Rule interface

func (*UpdateTagValueRule) EndTSM

func (r *UpdateTagValueRule) EndTSM()

EndTSM implements Rule interface

func (*UpdateTagValueRule) EndWAL

func (r *UpdateTagValueRule) EndWAL()

EndWAL implements Rule interface

func (*UpdateTagValueRule) Flags

func (r *UpdateTagValueRule) Flags() int

Flags implements Rule interface

func (*UpdateTagValueRule) Start

func (r *UpdateTagValueRule) Start()

Start implements Rule interface

func (*UpdateTagValueRule) StartShard

func (r *UpdateTagValueRule) StartShard(info storage.ShardInfo)

StartShard implements Rule interface

func (*UpdateTagValueRule) StartTSM

func (r *UpdateTagValueRule) StartTSM(path string)

StartTSM implements Rule interface

func (*UpdateTagValueRule) StartWAL

func (r *UpdateTagValueRule) StartWAL(path string)

StartWAL implements Rule interface

func (*UpdateTagValueRule) WithLogger

func (r *UpdateTagValueRule) WithLogger(logger *log.Logger)

WithLogger sets the logger on the rule

Jump to

Keyboard shortcuts

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