Documentation ¶
Index ¶
- func CreateProxy(configPath string)
- func NewLogger(filePath string, level zapcore.Level, maxSize int, maxBackups int, maxAge int, ...) *zap.Logger
- func StatsHandler(w http.ResponseWriter, r *http.Request)
- type BackStats
- type BackendEnd
- type Banlance
- type Context
- type HeatchConfig
- type HeathMontior
- type LeakBucketLimiter
- type LimitInterface
- type LimitType
- type LimiterConfig
- type LogConfig
- type Proxy
- type ProxyConfig
- type QueueLimiter
- type Stat
- type TokenBucketLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateProxy ¶
func CreateProxy(configPath string)
Types ¶
type BackendEnd ¶
type BackendEnd struct { SvrStr string `json:"svrStr"` IsUp bool `json:"isUp"` // is Up or Down FailTimes int `json:"failTimes"` // 失败次数 RiseTimes int `json:"riseTimes"` // 连接成功的次数 }
BackendSvr Type
type Banlance ¶
type Banlance struct {
// contains filtered or unexported fields
}
func (*Banlance) GetBackEndServer ¶
获得后端服务器
func (*Banlance) Init ¶
func (this *Banlance) Init(backend []string, heatch HeatchConfig)
func (*Banlance) ServiceGovernance ¶
后端应用服务器服务治理
type Context ¶
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter }
func (*Context) ServerJson ¶
func (this *Context) ServerJson(data interface{})
type HeatchConfig ¶
type HeatchConfig struct { Interval int `yaml:"interval"` Rise int `yaml:"rise"` Fall int `yaml:"fall"` Timeout int `yaml:"timeout"` Type string `yaml:"type"` DefaultDown bool `yaml:"default_down"` CheckHttpSend string `yaml:"check_http_send"` CheckHttpExceptAlive []string `yaml:"check_http_expect_alive"` Port int `yaml:"port"` }
HeatchConfig Type
type HeathMontior ¶
type HeathMontior struct { }
HeatchMontior
func (*HeathMontior) HttpCheck ¶
func (this *HeathMontior) HttpCheck(hConfig HeatchConfig, backend map[string]*BackendEnd)
HttpCheck
func (*HeathMontior) TcpCheck ¶
func (this *HeathMontior) TcpCheck(hConfig HeatchConfig, backend map[string]*BackendEnd)
TcpCheck
type LeakBucketLimiter ¶
type LeakBucketLimiter struct {
// contains filtered or unexported fields
}
////////////////////////////LeakBucketLimiter///////////////////////////// 漏斗桶限流算法
func NewLeakBucketLimiter ¶
func NewLeakBucketLimiter(name string, cap uint, t int) *LeakBucketLimiter
func (*LeakBucketLimiter) Bind ¶
func (this *LeakBucketLimiter) Bind(handler func(conn interface{}))
bind handler function to handler
func (*LeakBucketLimiter) IsAvalivale ¶
func (this *LeakBucketLimiter) IsAvalivale() bool
func (*LeakBucketLimiter) SetWaitQueue ¶
func (this *LeakBucketLimiter) SetWaitQueue(conn interface{})
call handler function by conn
type LimitInterface ¶
type LimitInterface interface { IsAvalivale() bool Bind(handler func(conn interface{})) SetWaitQueue(conn interface{}) }
限流接口
type LimiterConfig ¶
type LogConfig ¶
type LogConfig struct { Level int8 `yaml:"level"` Path string `yaml:"path"` MaxSize int `yaml:"max_size"` MaxBackup int `yaml:"max_backup"` MaxAge int `yaml:"max_age"` Compress bool `yaml:"compress"` ServiceName string `yaml:"servicename"` }
LogConfig Type
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func (*Proxy) HandleConnect ¶
func (this *Proxy) HandleConnect(conn interface{})
func (*Proxy) InitProxy ¶
func (this *Proxy) InitProxy(proxyConfig *ProxyConfig)
func (*Proxy) StartBanlance ¶
func (this *Proxy) StartBanlance(proxyConfig *ProxyConfig)
type ProxyConfig ¶
type ProxyConfig struct { Bind string `yaml:"bind"` Backend []string `yaml:"backend"` Log LogConfig `yaml:"log"` Stats string `yaml:"stats"` Heatch HeatchConfig `yaml:"heatch"` Limter LimiterConfig `yaml:"limiter"` }
ProxyConfig Type
type QueueLimiter ¶
type QueueLimiter struct {
// contains filtered or unexported fields
}
/////////////////////////////QueueLimiter///////////////////////////// 通过队列实现限流
func NewQueueLimter ¶
func NewQueueLimter(waitLength, maxConn int) *QueueLimiter
NewQueueLimter *
waitLength-最大的等待处理的长度 maxConn-最大的并发处理长度
*
func (QueueLimiter) Bind ¶
func (this QueueLimiter) Bind(handler func(conn interface{}))
func (*QueueLimiter) SetWaitQueue ¶
func (this *QueueLimiter) SetWaitQueue(conn interface{})
限流器增加计数
type Stat ¶
type Stat struct {
// contains filtered or unexported fields
}
Stat Real Server States
func (*Stat) RegisterRoute ¶
注册路由处理函数
type TokenBucketLimiter ¶
type TokenBucketLimiter struct {
// contains filtered or unexported fields
}
令牌桶实现限流
func NewTokenBucketLimiter ¶
func NewTokenBucketLimiter(t int, token int) *TokenBucketLimiter
func (*TokenBucketLimiter) Bind ¶
func (this *TokenBucketLimiter) Bind(handler func(conn interface{}))
bind handler function to handler
func (*TokenBucketLimiter) IsAvalivale ¶
func (this *TokenBucketLimiter) IsAvalivale() bool
func (*TokenBucketLimiter) SetWaitQueue ¶
func (this *TokenBucketLimiter) SetWaitQueue(conn interface{})
call handler function by conn
Source Files ¶
Click to show internal directories.
Click to hide internal directories.