sentinel

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SENTINEL_DATASOURCE_ETCD  = "etcd"
	SENTINEL_DATASOURCE_FILES = "files"
)

Variables

View Source
var (
	WithError = base.WithError
)

Functions

func Entry added in v0.2.5

func Entry(resource string, opts ...EntryOption) (*SentinelEntry, *BlockError)

Entry 执行熔断策略.

func FromContext added in v0.6.1

func FromContext(ctx context.Context) *base.SentinelEntry

func WithContext added in v0.6.1

func WithContext(ctx context.Context, val *base.SentinelEntry) context.Context

Types

type BlockError added in v0.6.1

type BlockError = base.BlockError

type CircuitBreakerRule added in v0.6.1

type CircuitBreakerRule struct {
	Enable bool `json:"enable"`
	// resource name
	Resource string                  `json:"resource"`
	Strategy circuitbreaker.Strategy `json:"strategy"`
	// RetryTimeoutMs represents recovery timeout (in milliseconds) before the circuit breaker opens.
	// During the open period, no requests are permitted until the timeout has elapsed.
	// After that, the circuit breaker will transform to half-open state for trying a few "trial" requests.
	RetryTimeoutMs uint32 `json:"retryTimeoutMs"`
	// MinRequestAmount represents the minimum number of requests (in an active statistic time span)
	// that can trigger circuit breaking.
	MinRequestAmount uint64 `json:"minRequestAmount"`
	// StatIntervalMs represents statistic time interval of the internal circuit breaker (in ms).
	// Currently the statistic interval is collected by sliding window.
	StatIntervalMs uint32 `json:"statIntervalMs"`
	// StatSlidingWindowBucketCount represents the bucket count of statistic sliding window.
	// The statistic will be more precise as the bucket count increases, but the memory cost increases too.
	// The following must be true — “StatIntervalMs % StatSlidingWindowBucketCount == 0”,
	// otherwise StatSlidingWindowBucketCount will be replaced by 1.
	// If it is not set, default value 1 will be used.
	StatSlidingWindowBucketCount uint32 `json:"statSlidingWindowBucketCount"`
	// MaxAllowedRtMs indicates that any invocation whose response time exceeds this value (in ms)
	// will be recorded as a slow request.
	// MaxAllowedRtMs only takes effect for SlowRequestRatio strategy
	MaxAllowedRtMs uint64 `json:"maxAllowedRtMs"`
	// Threshold represents the threshold of circuit breaker.
	// for SlowRequestRatio, it represents the max slow request ratio
	// for ErrorRatio, it represents the max error request ratio
	// for ErrorCount, it represents the max error request count
	Threshold float64 `json:"threshold"`
}

type Config

type Config struct {
	Enable     bool   `toml:"enable"`
	Datasource string `toml:"datasource"`
	EtcdRawKey string `toml:"etcdRawKey"`
	// 熔断降级
	CbKey   string                `toml:"cbKey"`
	CbRules []*CircuitBreakerRule `toml:"cbRules"`
	// 流量控制
	FlowKey   string       `toml:"flowKey"`
	FlowRules []*flow.Rule `toml:"flowRules"`
	// 系统保护
	SystemKey   string         `toml:"systemKey"`
	SystemRules []*system.Rule `toml:"systemRules"`
}

func DefaultConfig

func DefaultConfig() Config

func RawConfig

func RawConfig(key string) Config

func StdConfig added in v0.2.5

func StdConfig() Config

func (Config) Build added in v0.2.5

func (c Config) Build() error

func (Config) Entry added in v0.6.1

func (c Config) Entry(resource string, opts ...EntryOption) (*SentinelEntry, *BlockError)

type EntryContext added in v0.6.1

type EntryContext = base.EntryContext

type EntryOption added in v0.6.1

type EntryOption = sentinel.EntryOption

type SentinelEntry added in v0.6.1

type SentinelEntry = base.SentinelEntry

Jump to

Keyboard shortcuts

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