aspect

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FallbackErr = errors.New("skip fallback error")

FallbackErr 降级错误

Functions

This section is empty.

Types

type Debug

type Debug struct {
}

Debug 节点debug日志切面

func (*Debug) After

func (aspect *Debug) After(ctx types.RuleContext, msg types.RuleMsg, err error, relationType string) types.RuleMsg

func (*Debug) Before

func (aspect *Debug) Before(ctx types.RuleContext, msg types.RuleMsg, relationType string) types.RuleMsg

func (*Debug) Order

func (aspect *Debug) Order() int

func (*Debug) PointCut

func (aspect *Debug) PointCut(ctx types.RuleContext, msg types.RuleMsg, relationType string) bool

PointCut 切入点 所有节点都会执行

type NodeError

type NodeError struct {
	// contains filtered or unexported fields
}

NodeError 节点错误记录

type SkipFallbackAspect

type SkipFallbackAspect struct {
	// ErrorCountLimit LimitDuration 错误次数达到多少后,执行跳过降级
	ErrorCountLimit int64
	// LimitDuration 限制降级的时长
	LimitDuration time.Duration
	// PointCutFunc 切入点,默认所有
	// 用于判断是否需要执行降级逻辑
	// 若返回true,则执行降级逻辑
	// 若返回false,则不执行降级逻辑
	PointCutFunc func(ctx types.RuleContext, msg types.RuleMsg, relationType string) bool
	// contains filtered or unexported fields
}

SkipFallbackAspect 组件故障降级切面 降级逻辑: 1. 节点执行错误次数达到 ErrorCountLimit 后,执行跳过降级 2. 节点执行时间超过 LimitDuration 后,恢复执行

func (*SkipFallbackAspect) After

func (aspect *SkipFallbackAspect) After(ctx types.RuleContext, msg types.RuleMsg, err error, relationType string) types.RuleMsg

After 如果出现错误,则记录错误次数

func (*SkipFallbackAspect) Around

func (aspect *SkipFallbackAspect) Around(ctx types.RuleContext, msg types.RuleMsg, relationType string) (types.RuleMsg, bool)

Around 判断是否执行降级逻辑

func (*SkipFallbackAspect) OnDestroy

func (aspect *SkipFallbackAspect) OnDestroy(ctx types.NodeCtx)

func (*SkipFallbackAspect) OnReload

func (aspect *SkipFallbackAspect) OnReload(parentCtx types.NodeCtx, ctx types.NodeCtx, err error)

OnReload 节点更新清除错误缓存

func (*SkipFallbackAspect) Order

func (aspect *SkipFallbackAspect) Order() int

func (*SkipFallbackAspect) PointCut

func (aspect *SkipFallbackAspect) PointCut(ctx types.RuleContext, msg types.RuleMsg, relationType string) bool

PointCut 判断是否执行降级逻辑 可以指定某类型的节点执行降级逻辑,默认所有节点执行降级逻辑。可以被 PointCutFunc 覆盖

Jump to

Keyboard shortcuts

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