labeler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyRange is the rule type that specifies a list of key ranges.
	KeyRange = "key-range"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyRangeRule

type KeyRangeRule struct {
	StartKey    []byte `json:"-"`         // range start key
	StartKeyHex string `json:"start_key"` // hex format start key, for marshal/unmarshal
	EndKey      []byte `json:"-"`         // range end key
	EndKeyHex   string `json:"end_key"`   // hex format end key, for marshal/unmarshal
}

KeyRangeRule contains the start key and end key of the LabelRule. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

type LabelRule

type LabelRule struct {
	ID       string        `json:"id"`
	Index    int           `json:"index"`
	Labels   []RegionLabel `json:"labels"`
	RuleType string        `json:"rule_type"`
	Data     interface{}   `json:"data"`
	// contains filtered or unexported fields
}

LabelRule is the rule to assign labels to a region. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

type LabelRulePatch

type LabelRulePatch struct {
	SetRules    []*LabelRule `json:"sets"`
	DeleteRules []string     `json:"deletes"`
}

LabelRulePatch is the patch to update the label rules. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

type RegionLabel

type RegionLabel struct {
	Key     string `json:"key"`
	Value   string `json:"value"`
	TTL     string `json:"ttl,omitempty"`
	StartAt string `json:"start_at,omitempty"`
	// contains filtered or unexported fields
}

RegionLabel is the label of a region. NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.

type RegionLabeler

type RegionLabeler struct {
	syncutil.RWMutex
	// contains filtered or unexported fields
}

RegionLabeler is utility to label regions.

func NewRegionLabeler

func NewRegionLabeler(ctx context.Context, storage endpoint.RuleStorage, gcInterval time.Duration) (*RegionLabeler, error)

NewRegionLabeler creates a Labeler instance.

func (*RegionLabeler) DeleteLabelRule

func (l *RegionLabeler) DeleteLabelRule(id string) error

DeleteLabelRule removes a LabelRule.

func (*RegionLabeler) GetAllLabelRules

func (l *RegionLabeler) GetAllLabelRules() []*LabelRule

GetAllLabelRules returns all the rules.

func (*RegionLabeler) GetLabelRule

func (l *RegionLabeler) GetLabelRule(id string) *LabelRule

GetLabelRule returns the Rule with the same ID.

func (*RegionLabeler) GetLabelRules

func (l *RegionLabeler) GetLabelRules(ids []string) ([]*LabelRule, error)

GetLabelRules returns the rules that match the given ids.

func (*RegionLabeler) GetRegionLabel

func (l *RegionLabeler) GetRegionLabel(region *core.RegionInfo, key string) string

GetRegionLabel returns the label of the region for a key. If there are multiple rules that match the key, the one with max rule index will be returned.

func (*RegionLabeler) GetRegionLabels

func (l *RegionLabeler) GetRegionLabels(region *core.RegionInfo) []*RegionLabel

GetRegionLabels returns the labels of the region. For each key, the label with max rule index will be returned.

func (*RegionLabeler) GetSplitKeys

func (l *RegionLabeler) GetSplitKeys(start, end []byte) [][]byte

GetSplitKeys returns all split keys in the range (start, end).

func (*RegionLabeler) Patch

func (l *RegionLabeler) Patch(patch LabelRulePatch) error

Patch updates multiple region rules in a batch.

func (*RegionLabeler) ScheduleDisabled

func (l *RegionLabeler) ScheduleDisabled(region *core.RegionInfo) bool

ScheduleDisabled returns true if the region is lablelld with schedule-disabled.

func (*RegionLabeler) SetLabelRule

func (l *RegionLabeler) SetLabelRule(rule *LabelRule) error

SetLabelRule inserts or updates a LabelRule.

Jump to

Keyboard shortcuts

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