decorator

package
v0.0.0-...-47e18b9 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package decorator contains all implementations of LabelStrategy.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNS          = errorx.NewNamespace("error.keyvisual")
	ErrNSDecorator = ErrNS.NewSubNamespace("decorator")
	ErrInvalidData = ErrNSDecorator.NewType("invalid_data")
)

Functions

This section is empty.

Types

type LabelKey

type LabelKey struct {
	Key    string   `json:"key" binding:"required"`
	Labels []string `json:"labels" binding:"required"`
}

LabelKey is the decoration key.

type LabelStrategy

type LabelStrategy interface {
	ReloadConfig(cfg *config.KeyVisualConfig)
	// CrossBorder determines whether two keys not belong to the same logical range.
	CrossBorder(startKey, endKey string) bool
	// Label returns the Label information of the key.
	// Note: When the key is "", need to use LabelGlobalStart or LabelGlobalEnd.
	Label(key string) LabelKey
	LabelGlobalStart() LabelKey
	LabelGlobalEnd() LabelKey
}

LabelStrategy requires cross-border determination and key decoration scheme.

func SeparatorLabelStrategy

func SeparatorLabelStrategy(cfg *config.KeyVisualConfig) LabelStrategy

func TiDBLabelStrategy

func TiDBLabelStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, cfg *config.Config, etcdClient *clientv3.Client, tidbClient *tidb.Client) LabelStrategy

TiDBLabelStrategy implements the LabelStrategy interface. Get Label Information from TiDB.

type NaiveLabelStrategy

type NaiveLabelStrategy struct{}

NaiveLabelStrategy is one of the simplest LabelStrategy.

func (NaiveLabelStrategy) CrossBorder

func (s NaiveLabelStrategy) CrossBorder(startKey, endKey string) bool

CrossBorder always returns false. So NaiveLabelStrategy believes that there are no cross-border situations.

func (NaiveLabelStrategy) Label

func (s NaiveLabelStrategy) Label(key string) LabelKey

Label only decodes the key.

func (NaiveLabelStrategy) LabelGlobalEnd

func (s NaiveLabelStrategy) LabelGlobalEnd() LabelKey

func (NaiveLabelStrategy) LabelGlobalStart

func (s NaiveLabelStrategy) LabelGlobalStart() LabelKey

func (NaiveLabelStrategy) ReloadConfig

func (s NaiveLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig)

Jump to

Keyboard shortcuts

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