decorator

package
v0.0.0-...-0119d12 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

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)
	NewLabeler() Labeler
}

LabelStrategy requires cross-border determination and key decoration scheme. It supports dynamic reload configuration and generation of an actuator.

func NaiveLabelStrategy

func NaiveLabelStrategy() LabelStrategy

NaiveLabelStrategy is one of the simplest LabelStrategy.

func SeparatorLabelStrategy

func SeparatorLabelStrategy(cfg *config.KeyVisualConfig) LabelStrategy

SeparatorLabelStrategy implements the LabelStrategy interface. It obtains label information after splitting the key.

func TiDBLabelStrategy

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

TiDBLabelStrategy implements the LabelStrategy interface. It obtains Label Information from TiDB.

type Labeler

type Labeler interface {
	// CrossBorder determines whether two keys not belong to the same logical range.
	CrossBorder(startKey, endKey string) bool
	// Label returns the Label information of the keys.
	Label(keys []string) []LabelKey
}

Labeler is an executor of LabelStrategy, and its functions should not be called concurrently.

Jump to

Keyboard shortcuts

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