Documentation ¶
Index ¶
- func GetAPIKeyPresent(key APIKey) string
- func GlobalDestroy()
- func GlobalInitialize(c *Config)
- func PoolPutAPICallStatValueImpl(value *APICallStatValueImpl)
- func PoolPutRateLimitStatValueV1(value *RateLimitStatValueV1)
- func PoolPutRateLimitStatValueV2(value *RateLimitStatValueV2)
- func RegisterPlugin(name string, plugin Plugin)
- type APICallStatKey
- type APICallStatValue
- type APICallStatValueImpl
- func (a *APICallStatValueImpl) AddLatency(delta int64)
- func (a *APICallStatValueImpl) AddReqCount(delta int32)
- func (a *APICallStatValueImpl) CasMaxLatency(value int64)
- func (a *APICallStatValueImpl) Clone() APICallStatValue
- func (a APICallStatValueImpl) GetAPIName() string
- func (a APICallStatValueImpl) GetCode() uint32
- func (a *APICallStatValueImpl) GetDuration() string
- func (a *APICallStatValueImpl) GetLastUpdateTime() int64
- func (a *APICallStatValueImpl) GetLatency() int64
- func (a *APICallStatValueImpl) GetMaxLatency() int64
- func (a APICallStatValueImpl) GetMsgType() MsgType
- func (a *APICallStatValueImpl) GetReqCount() int32
- func (a *APICallStatValueImpl) GetStatKey() APICallStatKey
- func (a *APICallStatValueImpl) ResetMaxLatency(lastValue int64)
- func (a *APICallStatValueImpl) SetLastUpdateTime(now int64)
- type APIKey
- type Config
- type ConfigEntry
- type EventToLog
- type MsgType
- type Plugin
- type RateLimitData
- type RateLimitStatCollector
- type RateLimitStatCollectorV1
- type RateLimitStatCollectorV2
- type RateLimitStatCounterKeyV1
- type RateLimitStatCounterKeyV2
- type RateLimitStatKeyV1
- type RateLimitStatKeyV2
- type RateLimitStatValue
- type RateLimitStatValueV1
- func (r *RateLimitStatValueV1) Clone() RateLimitStatValue
- func (r RateLimitStatValueV1) GetAppId() string
- func (r RateLimitStatValueV1) GetClientIPStr() string
- func (r *RateLimitStatValueV1) GetCurveData() RateLimitData
- func (r RateLimitStatValueV1) GetDuration() time.Duration
- func (r *RateLimitStatValueV1) GetExpireDuration() int64
- func (r RateLimitStatValueV1) GetLabels() string
- func (r *RateLimitStatValueV1) GetLastUpdateTime() int64
- func (r RateLimitStatValueV1) GetMethod() string
- func (r RateLimitStatValueV1) GetNamespace() string
- func (r *RateLimitStatValueV1) GetPrecisionData() RateLimitData
- func (r RateLimitStatValueV1) GetService() string
- func (r RateLimitStatValueV1) GetStatKey(counterOnly bool) interface{}
- func (r RateLimitStatValueV1) GetTotal() int64
- func (r RateLimitStatValueV1) GetUin() string
- func (r *RateLimitStatValueV1) SetExpireDuration(value int64)
- func (r *RateLimitStatValueV1) SetLastUpdateTime(now int64)
- type RateLimitStatValueV2
- func (r *RateLimitStatValueV2) Clone() RateLimitStatValue
- func (r RateLimitStatValueV2) GetAppId() string
- func (r RateLimitStatValueV2) GetClientIPStr() string
- func (r *RateLimitStatValueV2) GetCurveData() RateLimitData
- func (r RateLimitStatValueV2) GetDuration() time.Duration
- func (r *RateLimitStatValueV2) GetExpireDuration() int64
- func (r RateLimitStatValueV2) GetLabels() string
- func (r *RateLimitStatValueV2) GetLastUpdateTime() int64
- func (r RateLimitStatValueV2) GetMethod() string
- func (r RateLimitStatValueV2) GetNamespace() string
- func (r *RateLimitStatValueV2) GetPrecisionData() RateLimitData
- func (r RateLimitStatValueV2) GetService() string
- func (r RateLimitStatValueV2) GetStatKey(counterOnly bool) interface{}
- func (r *RateLimitStatValueV2) GetTotal() int64
- func (r RateLimitStatValueV2) GetUin() string
- func (r *RateLimitStatValueV2) SetExpireDuration(value int64)
- func (r *RateLimitStatValueV2) SetLastUpdateTime(now int64)
- type Statis
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PoolPutAPICallStatValueImpl ¶
func PoolPutAPICallStatValueImpl(value *APICallStatValueImpl)
PoolPutAPICallStatValueImpl 池子回收RateLimitStatValue
func PoolPutRateLimitStatValueV1 ¶
func PoolPutRateLimitStatValueV1(value *RateLimitStatValueV1)
PoolPutRateLimitStatValueV1 池子回收RateLimitStatValue
func PoolPutRateLimitStatValueV2 ¶
func PoolPutRateLimitStatValueV2(value *RateLimitStatValueV2)
PoolPutRateLimitStatValueV2 池子回收RateLimitStatValue
Types ¶
type APICallStatKey ¶
APICallStatKey v2版本的服务调用
type APICallStatValue ¶
type APICallStatValue interface { // GetStatKey 获取统计的Key GetStatKey() APICallStatKey // GetAPIName 获取接口名 GetAPIName() string // GetCode 获取返回码 GetCode() uint32 // GetMsgType 获取消息类型 GetMsgType() MsgType // GetDuration 获取限流周期 GetDuration() string // GetReqCount 获取请求总数 GetReqCount() int32 // AddReqCount 增加请求总数 AddReqCount(int32) // GetLatency 获取接口调用时延 GetLatency() int64 // AddLatency 增加时延总数 AddLatency(int64) // GetMaxLatency 获取最大时延 GetMaxLatency() int64 // CasMaxLatency CAS设置最大时延 CasMaxLatency(int64) // ResetMaxLatency 重置最大时延 ResetMaxLatency(lastValue int64) // GetLastUpdateTime 获取最近一次更新时间 GetLastUpdateTime() int64 // SetLastUpdateTime 设置最近一次更新时间 SetLastUpdateTime(now int64) // Clone 复制对象,并重置变量值 Clone() APICallStatValue }
APICallStatValue 接口调用统计内容
type APICallStatValueImpl ¶
type APICallStatValueImpl struct { StatKey APICallStatKey // 接口调用时延,单位:us Latency int64 // 下面是结构复用的预留字段,传入时无需填入 ReqCount int32 MaxLatency int64 LastUpdateTime int64 }
APICallStatValueImpl v2版本的服务调用
func PoolGetAPICallStatValueImpl ¶
func PoolGetAPICallStatValueImpl() *APICallStatValueImpl
PoolGetAPICallStatValueImpl 池子获取RateLimitStatValue
func (*APICallStatValueImpl) AddLatency ¶
func (a *APICallStatValueImpl) AddLatency(delta int64)
AddLatency 增加时延总数
func (*APICallStatValueImpl) AddReqCount ¶
func (a *APICallStatValueImpl) AddReqCount(delta int32)
AddReqCount 增加请求总数
func (*APICallStatValueImpl) CasMaxLatency ¶
func (a *APICallStatValueImpl) CasMaxLatency(value int64)
CasMaxLatency CAS设置最大时延
func (*APICallStatValueImpl) Clone ¶
func (a *APICallStatValueImpl) Clone() APICallStatValue
Clone 复制对象,并重置变量值
func (APICallStatValueImpl) GetAPIName ¶
func (a APICallStatValueImpl) GetAPIName() string
GetAPIName 获取接口名
func (*APICallStatValueImpl) GetDuration ¶
func (a *APICallStatValueImpl) GetDuration() string
GetDuration 获取标签值
func (*APICallStatValueImpl) GetLastUpdateTime ¶
func (a *APICallStatValueImpl) GetLastUpdateTime() int64
GetLastUpdateTime 获取最近一次更新时间
func (*APICallStatValueImpl) GetLatency ¶
func (a *APICallStatValueImpl) GetLatency() int64
GetLatency 获取接口调用时延
func (*APICallStatValueImpl) GetMaxLatency ¶
func (a *APICallStatValueImpl) GetMaxLatency() int64
GetMaxLatency 获取最大时延
func (APICallStatValueImpl) GetMsgType ¶
func (a APICallStatValueImpl) GetMsgType() MsgType
GetMsgType 获取消息类型
func (*APICallStatValueImpl) GetReqCount ¶
func (a *APICallStatValueImpl) GetReqCount() int32
GetReqCount 获取请求总数
func (*APICallStatValueImpl) GetStatKey ¶
func (a *APICallStatValueImpl) GetStatKey() APICallStatKey
GetStatKey 获取统计的Key
func (*APICallStatValueImpl) ResetMaxLatency ¶
func (a *APICallStatValueImpl) ResetMaxLatency(lastValue int64)
ResetMaxLatency 重置最大时延
func (*APICallStatValueImpl) SetLastUpdateTime ¶
func (a *APICallStatValueImpl) SetLastUpdateTime(now int64)
SetLastUpdateTime 设置最近一次更新时间
type Config ¶
type Config struct { Storage *ConfigEntry `yaml:"storage"` Statis *ConfigEntry `yaml:"statis"` }
Config 插件总配置
type ConfigEntry ¶
ConfigEntry 每个插件配置
type EventToLog ¶
type EventToLog interface { // GetEventType 获取事件类型 GetEventType() string // ToJson 变成Json输出 ToJson() string }
EventToLog 可输出的事件
type Plugin ¶
type Plugin interface { Name() string Initialize(c *ConfigEntry) error Destroy() error }
Plugin 通用插件接口
type RateLimitData ¶
type RateLimitData interface { // GetPassed 获取通过数 GetPassed() int64 // AddPassed 增加通过数 AddPassed(delta int64) // GetLimited 获取限流数 GetLimited() int64 // AddLimited 增加限流数 AddLimited(delta int64) // AddValues 增加统计数据 AddValues(data RateLimitData) // InitValues 初始化数据结构 InitValues(passed int64, limited int64, lastFetchTime int64) // SetLastFetchTime 设置最后一次拉取时间 SetLastFetchTime(timeMs int64) // GetLastFetchTime 获得最后一次拉取时间 GetLastFetchTime() int64 }
RateLimitData 限流统计数据
type RateLimitStatCollector ¶
type RateLimitStatCollector interface { // ID 获取ID信息 ID() string // DumpAndExpire 拷贝并解引用 DumpAndExpire(valueSlice []RateLimitStatValue, enableExpire bool) ([]RateLimitStatValue, int) }
RateLimitStatCollector 采集器
type RateLimitStatCollectorV1 ¶
type RateLimitStatCollectorV1 struct {
// contains filtered or unexported fields
}
RateLimitStatCollectorV1 限流上报收集齐
func NewRateLimitStatCollectorV1 ¶
func NewRateLimitStatCollectorV1() *RateLimitStatCollectorV1
NewRateLimitStatCollectorV1 构造函数
func (*RateLimitStatCollectorV1) AddStatValueV1 ¶
func (r *RateLimitStatCollectorV1) AddStatValueV1(value *RateLimitStatValueV1)
AddStatValueV1 新增值信息
func (*RateLimitStatCollectorV1) DumpAndExpire ¶
func (r *RateLimitStatCollectorV1) DumpAndExpire( valueSlice []RateLimitStatValue, enableExpire bool) ([]RateLimitStatValue, int)
DumpAndExpire 拷贝并解引用
type RateLimitStatCollectorV2 ¶
type RateLimitStatCollectorV2 struct {
// contains filtered or unexported fields
}
RateLimitStatCollectorV2 限流上报收集齐
func NewRateLimitStatCollectorV2 ¶
func NewRateLimitStatCollectorV2() *RateLimitStatCollectorV2
NewRateLimitStatCollectorV2 构造函数
func (*RateLimitStatCollectorV2) AddStatValueV2 ¶
func (r *RateLimitStatCollectorV2) AddStatValueV2(value *RateLimitStatValueV2)
AddStatValueV2 新增值信息
func (*RateLimitStatCollectorV2) DumpAndExpire ¶
func (r *RateLimitStatCollectorV2) DumpAndExpire( valueSlice []RateLimitStatValue, enableExpire bool) ([]RateLimitStatValue, int)
DumpAndExpire 拷贝并解引用
type RateLimitStatCounterKeyV1 ¶
type RateLimitStatCounterKeyV1 struct { Namespace string Service string Method string AppId string Uin string Labels string Duration time.Duration }
RateLimitStatCounterKeyV1 限流key v1,只带入counter信息
type RateLimitStatCounterKeyV2 ¶
type RateLimitStatCounterKeyV2 struct { // CounterKey 新版本上报的API有CounterKey CounterKey uint32 }
RateLimitStatCounterKeyV2 限流key,只带入counter信息
type RateLimitStatKeyV1 ¶
type RateLimitStatKeyV1 struct { RateLimitStatCounterKeyV1 ClientIP utils.IPAddress }
RateLimitStatKeyV1 限流key v1
type RateLimitStatKeyV2 ¶
type RateLimitStatKeyV2 struct { RateLimitStatCounterKeyV2 ClientIP utils.IPAddress }
RateLimitStatKeyV2 限流key
type RateLimitStatValue ¶
type RateLimitStatValue interface { // GetStatKey 获取统计的Key GetStatKey(bool) interface{} // GetClientIPStr 获取客户端IP字符串 GetClientIPStr() string // GetNamespace 获取命名空间 GetNamespace() string // GetService 获取服务名 GetService() string // GetMethod 获取接口名 GetMethod() string // GetAppId 获取应用标识 GetAppId() string // GetUin 获取用户标识 GetUin() string // GetLabels 获取自定义标签 GetLabels() string // GetDuration 获取限流周期 GetDuration() time.Duration // GetTotal 获取请求总数 GetTotal() int64 // GetCurveData 获取曲线上报数据 GetCurveData() RateLimitData // GetPrecisionData 获取精度上报的数据 GetPrecisionData() RateLimitData // GetExpireDuration 获取超时周期 GetExpireDuration() int64 // SetExpireDuration 设置超时周期 SetExpireDuration(value int64) // GetLastUpdateTime 获取最近一次更新时间,单位毫秒 GetLastUpdateTime() int64 // SetLastUpdateTime 设置最近一次更新时间 SetLastUpdateTime(now int64) // Clone 复制对象,并重置变量值 Clone() RateLimitStatValue }
RateLimitStatValue 接口调用统计内容
type RateLimitStatValueV1 ¶
type RateLimitStatValueV1 struct { StatKey RateLimitStatKeyV1 Total int64 CurveData rateLimitData PrecisionData rateLimitData // 下面是结构复用的预留字段,传入时无需填入 LastUpdateTime int64 ExpireDuration int64 }
RateLimitStatValueV1 限流value v1
func PoolGetRateLimitStatValueV1 ¶
func PoolGetRateLimitStatValueV1() *RateLimitStatValueV1
PoolGetRateLimitStatValueV1 池子获取RateLimitStatValue
func (*RateLimitStatValueV1) Clone ¶
func (r *RateLimitStatValueV1) Clone() RateLimitStatValue
Clone 复制对象,并重置变量值
func (RateLimitStatValueV1) GetAppId ¶
func (r RateLimitStatValueV1) GetAppId() string
GetAppId 获取应用标识
func (RateLimitStatValueV1) GetClientIPStr ¶
func (r RateLimitStatValueV1) GetClientIPStr() string
GetClientIPStr 获取客户端IP字符串
func (*RateLimitStatValueV1) GetCurveData ¶
func (r *RateLimitStatValueV1) GetCurveData() RateLimitData
GetCurveData 获取通过数
func (RateLimitStatValueV1) GetDuration ¶
func (r RateLimitStatValueV1) GetDuration() time.Duration
GetDuration 获取限流周期
func (*RateLimitStatValueV1) GetExpireDuration ¶
func (r *RateLimitStatValueV1) GetExpireDuration() int64
GetExpireDuration 获取超时周期
func (RateLimitStatValueV1) GetLabels ¶
func (r RateLimitStatValueV1) GetLabels() string
GetLabels 获取自定义标签
func (*RateLimitStatValueV1) GetLastUpdateTime ¶
func (r *RateLimitStatValueV1) GetLastUpdateTime() int64
GetLastUpdateTime 获取最近一次更新时间
func (RateLimitStatValueV1) GetMethod ¶
func (r RateLimitStatValueV1) GetMethod() string
GetMethod 获取接口名
func (RateLimitStatValueV1) GetNamespace ¶
func (r RateLimitStatValueV1) GetNamespace() string
GetNamespace 获取命名空间
func (*RateLimitStatValueV1) GetPrecisionData ¶
func (r *RateLimitStatValueV1) GetPrecisionData() RateLimitData
GetPrecisionData 获取限流数
func (RateLimitStatValueV1) GetService ¶
func (r RateLimitStatValueV1) GetService() string
GetService 获取服务名
func (RateLimitStatValueV1) GetStatKey ¶
func (r RateLimitStatValueV1) GetStatKey(counterOnly bool) interface{}
GetStatKey 获取统计的Key
func (RateLimitStatValueV1) GetTotal ¶
func (r RateLimitStatValueV1) GetTotal() int64
GetTotal获取请求总数
func (*RateLimitStatValueV1) SetExpireDuration ¶
func (r *RateLimitStatValueV1) SetExpireDuration(value int64)
SetExpireDuration 设置超时周期
func (*RateLimitStatValueV1) SetLastUpdateTime ¶
func (r *RateLimitStatValueV1) SetLastUpdateTime(now int64)
SetLastUpdateTime 设置最近一次更新时间
type RateLimitStatValueV2 ¶
type RateLimitStatValueV2 struct { StatKey RateLimitStatKeyV2 Total int64 CurveData rateLimitData PrecisionData rateLimitData // 使用CounterKey则需要填以下字段 Namespace string Service string Method string AppId string Uin string Labels string Duration time.Duration // 超时间隔,单位毫秒 ExpireDuration int64 // 下面是结构复用的预留字段,传入时无需填入 LastUpdateTime int64 }
RateLimitStatValueV2 限流value
func PoolGetRateLimitStatValueV2 ¶
func PoolGetRateLimitStatValueV2() *RateLimitStatValueV2
PoolGetRateLimitStatValueV2 池子获取RateLimitStatValue
func (*RateLimitStatValueV2) Clone ¶
func (r *RateLimitStatValueV2) Clone() RateLimitStatValue
Clone 复制对象,并重置变量值
func (RateLimitStatValueV2) GetAppId ¶
func (r RateLimitStatValueV2) GetAppId() string
GetAppId 获取应用标识
func (RateLimitStatValueV2) GetClientIPStr ¶
func (r RateLimitStatValueV2) GetClientIPStr() string
GetClientIPStr 获取客户端IP字符串
func (*RateLimitStatValueV2) GetCurveData ¶
func (r *RateLimitStatValueV2) GetCurveData() RateLimitData
GetCurveData 获取通过数
func (RateLimitStatValueV2) GetDuration ¶
func (r RateLimitStatValueV2) GetDuration() time.Duration
GetDuration 获取限流周期
func (*RateLimitStatValueV2) GetExpireDuration ¶
func (r *RateLimitStatValueV2) GetExpireDuration() int64
GetExpireDuration 获取超时周期
func (RateLimitStatValueV2) GetLabels ¶
func (r RateLimitStatValueV2) GetLabels() string
GetLabels 获取自定义标签
func (*RateLimitStatValueV2) GetLastUpdateTime ¶
func (r *RateLimitStatValueV2) GetLastUpdateTime() int64
GetLastUpdateTime 获取最近一次更新时间,单位毫秒
func (RateLimitStatValueV2) GetMethod ¶
func (r RateLimitStatValueV2) GetMethod() string
GetMethod 获取接口名
func (RateLimitStatValueV2) GetNamespace ¶
func (r RateLimitStatValueV2) GetNamespace() string
GetNamespace 获取命名空间
func (*RateLimitStatValueV2) GetPrecisionData ¶
func (r *RateLimitStatValueV2) GetPrecisionData() RateLimitData
GetPrecisionData 获取限流数
func (RateLimitStatValueV2) GetService ¶
func (r RateLimitStatValueV2) GetService() string
GetService 获取服务名
func (RateLimitStatValueV2) GetStatKey ¶
func (r RateLimitStatValueV2) GetStatKey(counterOnly bool) interface{}
GetStatKey 获取统计的Key
func (*RateLimitStatValueV2) GetTotal ¶
func (r *RateLimitStatValueV2) GetTotal() int64
GetTotal 获取请求总数
func (*RateLimitStatValueV2) SetExpireDuration ¶
func (r *RateLimitStatValueV2) SetExpireDuration(value int64)
SetExpireDuration 设置超时周期
func (*RateLimitStatValueV2) SetLastUpdateTime ¶
func (r *RateLimitStatValueV2) SetLastUpdateTime(now int64)
SetLastUpdateTime 设置最近一次更新时间
type Statis ¶
type Statis interface { Plugin // CreateRateLimitStatCollectorV1 创建采集器V1,每个stream上来后获取一次 CreateRateLimitStatCollectorV1() *RateLimitStatCollectorV1 // CreateRateLimitStatCollectorV2 创建采集器V2,每个stream上来后获取一次 CreateRateLimitStatCollectorV2() *RateLimitStatCollectorV2 // DropRateLimitStatCollector 归还采集器 DropRateLimitStatCollector(RateLimitStatCollector) // AddAPICall 服务方法调用结果反馈,含有规则的计算周期 AddAPICall(value APICallStatValue) // AddEventToLog 添加日志时间 AddEventToLog(value EventToLog) }
Statis 统计插件接口