Versions in this module Expand all Collapse all v0 v0.0.4 Sep 14, 2020 Changes in this version + const DefaultIntervalMs + const DefaultIntervalMsTotal + const DefaultMaxResourceAmount + const DefaultSampleCount + const DefaultSampleCountTotal + const DefaultStatisticMaxRt + const TotalInBoundResourceName + type BlockError struct + func NewBlockError(blockType BlockType) *BlockError + func NewBlockErrorFromDeepCopy(from *BlockError) *BlockError + func NewBlockErrorWithCause(blockType BlockType, blockMsg string, rule SentinelRule, snapshot interface{}) *BlockError + func NewBlockErrorWithMessage(blockType BlockType, message string) *BlockError + func (e *BlockError) BlockMsg() string + func (e *BlockError) BlockType() BlockType + func (e *BlockError) Error() string + func (e *BlockError) TriggeredRule() SentinelRule + func (e *BlockError) TriggeredValue() interface{} + type BlockType uint8 + const BlockTypeCircuitBreaking + const BlockTypeFlow + const BlockTypeHotSpotParamFlow + const BlockTypeSystemFlow + const BlockTypeUnknown + func (t BlockType) String() string + type EntryContext struct + Data map[interface{}]interface{} + Input *SentinelInput + Resource *ResourceWrapper + RuleCheckResult *TokenResult + StatNode StatNode + func NewEmptyEntryContext() *EntryContext + func (ctx *EntryContext) Entry() *SentinelEntry + func (ctx *EntryContext) Err() error + func (ctx *EntryContext) IsBlocked() bool + func (ctx *EntryContext) PutRt(rt uint64) + func (ctx *EntryContext) Reset() + func (ctx *EntryContext) Rt() uint64 + func (ctx *EntryContext) SetEntry(entry *SentinelEntry) + func (ctx *EntryContext) SetError(err error) + func (ctx *EntryContext) StartTime() uint64 + type ExitHandler func(entry *SentinelEntry, ctx *EntryContext) error + type ExitOption func(*ExitOptions) + func WithError(err error) ExitOption + type ExitOptions struct + type MetricEvent int8 + const MetricEventBlock + const MetricEventComplete + const MetricEventError + const MetricEventPass + const MetricEventRt + const MetricEventTotal + type MetricItem struct + AvgRt uint64 + BlockQps uint64 + Classification int32 + CompleteQps uint64 + Concurrency uint32 + ErrorQps uint64 + OccupiedPassQps uint64 + PassQps uint64 + Resource string + Timestamp uint64 + func MetricItemFromFatString(line string) (*MetricItem, error) + func (m *MetricItem) ToFatString() (string, error) + func (m *MetricItem) ToThinString() (string, error) + type MetricItemRetriever interface + MetricsOnCondition func(predicate TimePredicate) []*MetricItem + type ReadStat interface + AvgRT func() float64 + GetPreviousQPS func(event MetricEvent) float64 + GetQPS func(event MetricEvent) float64 + GetSum func(event MetricEvent) int64 + MinRT func() float64 + type ResourceType int32 + const ResTypeAPIGateway + const ResTypeCache + const ResTypeCommon + const ResTypeDBSQL + const ResTypeMQ + const ResTypeRPC + const ResTypeWeb + type ResourceWrapper struct + func NewResourceWrapper(name string, classification ResourceType, flowType TrafficType) *ResourceWrapper + func (r *ResourceWrapper) Classification() ResourceType + func (r *ResourceWrapper) FlowType() TrafficType + func (r *ResourceWrapper) Name() string + func (r *ResourceWrapper) String() string + type RuleCheckSlot interface + Check func(ctx *EntryContext) *TokenResult + type SentinelEntry struct + func NewSentinelEntry(ctx *EntryContext, rw *ResourceWrapper, sc *SlotChain) *SentinelEntry + func (e *SentinelEntry) Context() *EntryContext + func (e *SentinelEntry) Exit(exitOps ...ExitOption) + func (e *SentinelEntry) Resource() *ResourceWrapper + func (e *SentinelEntry) SetError(err error) + func (e *SentinelEntry) WhenExit(exitHandler ExitHandler) + type SentinelInput struct + AcquireCount uint32 + Args []interface{} + Attachments map[interface{}]interface{} + Flag int32 + type SentinelRule interface + ResourceName func() string + type SlotChain struct + func NewSlotChain() *SlotChain + func (sc *SlotChain) AddRuleCheckSlotFirst(s RuleCheckSlot) + func (sc *SlotChain) AddRuleCheckSlotLast(s RuleCheckSlot) + func (sc *SlotChain) AddStatPrepareSlotFirst(s StatPrepareSlot) + func (sc *SlotChain) AddStatPrepareSlotLast(s StatPrepareSlot) + func (sc *SlotChain) AddStatSlotFirst(s StatSlot) + func (sc *SlotChain) AddStatSlotLast(s StatSlot) + func (sc *SlotChain) Entry(ctx *EntryContext) *TokenResult + func (sc *SlotChain) GetPooledContext() *EntryContext + func (sc *SlotChain) RefurbishContext(c *EntryContext) + type StatNode interface + CurrentGoroutineNum func() int32 + DecreaseGoroutineNum func() + IncreaseGoroutineNum func() + Reset func() + type StatPrepareSlot interface + Prepare func(ctx *EntryContext) + type StatSlot interface + OnCompleted func(ctx *EntryContext) + OnEntryBlocked func(ctx *EntryContext, blockError *BlockError) + OnEntryPassed func(ctx *EntryContext) + type TimePredicate func(uint64) bool + type TokenResult struct + func NewTokenResultBlocked(blockType BlockType) *TokenResult + func NewTokenResultBlockedWithCause(blockType BlockType, blockMsg string, rule SentinelRule, snapshot interface{}) *TokenResult + func NewTokenResultBlockedWithMessage(blockType BlockType, blockMsg string) *TokenResult + func NewTokenResultPass() *TokenResult + func NewTokenResultShouldWait(waitMs uint64) *TokenResult + func (r *TokenResult) BlockError() *BlockError + func (r *TokenResult) DeepCopyFrom(newResult *TokenResult) + func (r *TokenResult) IsBlocked() bool + func (r *TokenResult) IsPass() bool + func (r *TokenResult) ResetToBlocked(blockType BlockType) + func (r *TokenResult) ResetToBlockedWithCause(blockType BlockType, blockMsg string, rule SentinelRule, snapshot interface{}) + func (r *TokenResult) ResetToBlockedWithMessage(blockType BlockType, blockMsg string) + func (r *TokenResult) ResetToPass() + func (r *TokenResult) Status() TokenResultStatus + func (r *TokenResult) String() string + func (r *TokenResult) WaitMs() uint64 + type TokenResultStatus uint8 + const ResultStatusBlocked + const ResultStatusPass + const ResultStatusShouldWait + func (s TokenResultStatus) String() string + type TrafficType int32 + const Inbound + const Outbound + func (t TrafficType) String() string + type WriteStat interface + AddMetric func(event MetricEvent, count uint64)