isolation

package
v1.0.0-M2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	RuleCheckSlotName = "sentinel-core-isolation-rule-check-slot"
)

Variables

View Source
var (
	DefaultSlot = &Slot{}
)

Functions

func ClearRules

func ClearRules() error

ClearRules clears all the rules in isolation module.

func IsValid

func IsValid(r *Rule) error

IsValidRule checks whether the given Rule is valid.

func LoadRules

func LoadRules(rules []*Rule) (updated bool, err error)

LoadRules loads the given isolation rules to the rule manager, while all previous rules will be replaced.

Types

type MetricType

type MetricType int32

MetricType represents the target metric type.

const (
	// Concurrency represents concurrency count.
	Concurrency MetricType = iota
)

func (MetricType) String

func (s MetricType) String() string

type Rule

type Rule struct {
	// ID represents the unique ID of the rule (optional).
	ID         string     `json:"id,omitempty"`
	Resource   string     `json:"resource"`
	MetricType MetricType `json:"metricType"`
	Threshold  uint32     `json:"threshold"`
}

Rule describes the concurrency num control, that is similar to semaphore

func GetRules

func GetRules() []Rule

GetRules returns all the rules based on copy. It doesn't take effect for isolation module if user changes the rule.

func GetRulesOfResource

func GetRulesOfResource(res string) []Rule

GetRulesOfResource returns specific resource's rules based on copy. It doesn't take effect for isolation module if user changes the rule.

func (*Rule) ResourceName

func (r *Rule) ResourceName() string

func (*Rule) String

func (r *Rule) String() string

type Slot

type Slot struct {
}

func (*Slot) Check

func (s *Slot) Check(ctx *base.EntryContext) *base.TokenResult

func (*Slot) Name

func (s *Slot) Name() string

Jump to

Keyboard shortcuts

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