isolation

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package isolation provides implementation of concurrency limiting (semaphore isolation).

Index

Constants

View Source
const (
	RuleCheckSlotOrder = 3000
)

Variables

View Source
var (
	DefaultSlot = &Slot{}
)

Functions

func ClearRules

func ClearRules() error

ClearRules clears all the rules in isolation module.

func ClearRulesOfResource

func ClearRulesOfResource(res string) error

ClearRulesOfResource clears resource level rules in isolation module.

func IsValidRule

func IsValidRule(r *Rule) error

IsValidRule checks whether the given Rule is valid.

func LoadRules

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

LoadRules loads the given isolation rules to the rule manager, while all previous rules will be replaced. the first returned value indicates whether do real load operation, if the rules is the same with previous rules, return false

func LoadRulesOfResource

func LoadRulesOfResource(res string, rules []*Rule) (bool, error)

LoadRulesOfResource loads the given resource's isolation rules to the rule manager, while all previous resource's rules will be replaced. the first returned value indicates whether do real load operation, if the rules is the same with previous resource's rules, return false

Types

type MetricType

type MetricType int32

MetricType represents the target metric type.

const (
	// Concurrency represents concurrency (in-flight requests).
	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 represents the target resource definition.
	Resource string `json:"resource"`
	// MetricType indicates the metric type for checking logic.
	// Currently Concurrency is supported for concurrency limiting.
	MetricType MetricType `json:"metricType"`
	Threshold  uint32     `json:"threshold"`
}

Rule describes the isolation policy (e.g. semaphore isolation).

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) Order

func (s *Slot) Order() uint32

Jump to

Keyboard shortcuts

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