Documentation ¶
Index ¶
- func NewListener(l net.Listener, protocol string, config *Config) (net.Listener, error)
- func RemoveLimitListener(protocol string)
- func SetLimitListener(lis *Listener) error
- type Config
- type Conn
- type HostConnStat
- type Listener
- func (l *Listener) Accept() (net.Conn, error)
- func (l *Listener) Close() error
- func (l *Listener) GetDistinctHostCount() int32
- func (l *Listener) GetHostActiveConns(host string) map[string]*Conn
- func (l *Listener) GetHostConnCount(host string) int32
- func (l *Listener) GetHostConnStats(host string) []*HostConnStat
- func (l *Listener) GetHostConnection(host string, port int) *Conn
- func (l *Listener) GetListenerConnCount() int32
- func (l *Listener) Range(fn func(host string, count int32) bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewListener ¶
NewListener returns a new listener @param l 网络连接 @param protocol 当前listener的七层协议,比如http,grpc等
func RemoveLimitListener ¶
func RemoveLimitListener(protocol string)
RemoveLimitListener 清理对应协议的链接计数
func SetLimitListener ¶
SetLimitListener 设置当前的listener 注意:Listener.protocol不能重复
Types ¶
type Config ¶
type Config struct { // 开启连接限制 OpenConnLimit bool `mapstructure:"openConnLimit"` // 单个host最大的连接数,必须 > 1 MaxConnPerHost int `mapstructure:"maxConnPerHost"` // 当前协议监听端口的最大连接数 // 兼容老版本,> 1,则开启listen的全局限制;< 1则不开启listen的全局限制 MaxConnLimit int `mapstructure:"maxConnLimit"` // 白名单,不进行host连接数限制 WhiteList string `mapstructure:"whiteList"` // 读超时 ReadTimeout time.Duration `mapstructure:"readTimeout"` // 回收连接统计数据的周期 PurgeCounterInterval time.Duration `mapstructure:"purgeCounterInterval"` // 回收连接的最大超时时间 PurgeCounterExpire time.Duration `mapstructure:"purgeCounterExpire"` }
Config 连接限制配置
func ParseConnLimitConfig ¶
ParseConnLimitConfig 解析配置
type HostConnStat ¶
HostConnStat 连接的统计信息
type Listener ¶
Listener 包装 net.Listener
func GetLimitListener ¶
GetLimitListener 获取当前的listener
func (*Listener) GetDistinctHostCount ¶
GetDistinctHostCount 获取当前缓存的host的个数
func (*Listener) GetHostActiveConns ¶
GetHostActiveConns 获取指定host的活跃的连接
func (*Listener) GetHostConnCount ¶
GetHostConnCount 查看对应ip的连接数
func (*Listener) GetHostConnStats ¶
func (l *Listener) GetHostConnStats(host string) []*HostConnStat
GetHostConnStats 获取客户端连接的stat信息
func (*Listener) GetHostConnection ¶
GetHostConnection 获取指定host和port的连接
func (*Listener) GetListenerConnCount ¶
GetListenerConnCount 查看当前监听server保持的连接数
Click to show internal directories.
Click to hide internal directories.