Documentation ¶
Index ¶
- Constants
- Variables
- type Gateway
- type Info
- type LatencyList
- func (ll LatencyList) Avg() time.Duration
- func (ll LatencyList) L90() time.Duration
- func (ll LatencyList) L95() time.Duration
- func (ll LatencyList) Len() int
- func (ll LatencyList) Less(i, j int) bool
- func (ll LatencyList) Max() time.Duration
- func (ll LatencyList) Min() time.Duration
- func (ll LatencyList) Swap(i, j int)
- type MethodInfo
- type Option
- type OptionsFunc
Constants ¶
View Source
const ( StatusNo = 0 StatusYes = 1 StatusBusy = 2 )
Variables ¶
View Source
var (
ErrTimeout = errors.New(`input timeout`)
)
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway interface { // In 接收请求 In(path string) (status uint8, exists bool) // InTimeout 带有超时时间的接收请求 InTimeout(timeout time.Duration, path string) (status uint8, exists bool, err error) // Out gateway响应 Out(accessTime time.Time, path string, code int) (dur time.Duration, qps int32, total uint64, err error) // Info 获取gateway信息 Info() (info Info) // Close 释放gateway资源 Close() (err error) }
func NewGateway ¶
func NewGateway(duration time.Duration, optionsFunc OptionsFunc) Gateway
NewGateway new gateway intance
type Info ¶
type Info struct { Qps int32 `json:"qps"` Total uint64 `json:"total"` MethodList []MethodInfo `json:"method_list"` }
Info gateway详情
type LatencyList ¶
LatencyList 方法延时列表
func (LatencyList) Avg ¶
func (ll LatencyList) Avg() time.Duration
func (LatencyList) L90 ¶
func (ll LatencyList) L90() time.Duration
func (LatencyList) L95 ¶
func (ll LatencyList) L95() time.Duration
func (LatencyList) Len ¶
func (ll LatencyList) Len() int
func (LatencyList) Less ¶
func (ll LatencyList) Less(i, j int) bool
func (LatencyList) Max ¶
func (ll LatencyList) Max() time.Duration
func (LatencyList) Min ¶
func (ll LatencyList) Min() time.Duration
func (LatencyList) Swap ¶
func (ll LatencyList) Swap(i, j int)
type MethodInfo ¶
type MethodInfo struct { Name string `json:"name"` Path string `json:"path"` SecondLimit int `json:"second_limit"` Qps int32 `json:"qps"` Total uint64 `json:"total"` Avg string `json:"avg"` Min string `json:"min"` Max string `json:"max"` L90 string `json:"90_line"` L95 string `json:"95_line"` CodeMap map[int]uint64 `json:"code_map"` // contains filtered or unexported fields }
MethodInfo 方法详情
type Option ¶
type Option struct { Name string `json:"name" yaml:"name"` Path string `json:"path" yaml:"path"` SecondLimit int `json:"second_limit" yaml:"second_limit"` }
Option 方法配置
type OptionsFunc ¶
type OptionsFunc func() (options []Option)
OptionsFunc 加载配置函数
func OptionsWithDb ¶
func OptionsWithDb(db *sql.DB, tableName string) (optionsFunc OptionsFunc)
OptionsWithDb 从数据库表加载配置
func OptionsWithJsonFile ¶
func OptionsWithJsonFile(filepath string) (optionsFunc OptionsFunc)
OptionsWithJsonFile 从Json文件加载配置
func OptionsWithRedis ¶
func OptionsWithRedis(red *redigo.Pool, hashKey string) (optionsFunc OptionsFunc)
OptionsWithRedis 从redis哈希Key加载配置
func OptionsWithYamlFile ¶
func OptionsWithYamlFile(filepath string) (optionsFunc OptionsFunc)
OptionsWithYamlFile 从Yaml文件加载配置
Click to show internal directories.
Click to hide internal directories.