Documentation ¶
Index ¶
- Constants
- func GetRealClientIP(ctx *fasthttp.RequestCtx) string
- func GetRuntimeContext(api *meta.Api) *runtimeContext
- func Hashcode(s string) int
- func Log(text string)
- func PathExists(path string) bool
- func SetAccessLogger(log core.AccessLogger)
- type AccessLogIntercepter
- type AuthIntercepter
- type BaseIntercepter
- type CiruitStatus
- type DefaultRouter
- type DispatchManager
- func (this *DispatchManager) AddApi(domain, clusterName string, api *meta.Api)
- func (this *DispatchManager) AddCluster(cluster *meta.ServerCluster)
- func (this *DispatchManager) AddServer(clusterName string, server *meta.Server)
- func (this *DispatchManager) DelApi(api *meta.Api)
- func (this *DispatchManager) DelCluster(name string)
- func (this *DispatchManager) DelServer(clusterName string, id int64)
- func (this *DispatchManager) GetApi(domain, url string) *meta.Api
- func (this *DispatchManager) GetCluster(name string) *meta.ServerCluster
- func (this *DispatchManager) Init()
- type FastHTTPClient
- type HTTPOption
- type Handle
- type HandlePlugin
- type HttpConfig
- type HttpProxy
- func (this *HttpProxy) AddIntercepter(i Intercepter)
- func (this *HttpProxy) AddPlugin(name string, plugin HandlePlugin)
- func (this *HttpProxy) Init(dispatch *DispatchManager)
- func (this *HttpProxy) ServeHTTP(ctx *fasthttp.RequestCtx)
- func (this *HttpProxy) SetConfig(config HttpConfig)
- func (this *HttpProxy) Start()
- type IPHash
- type Intercepter
- type LimitIntercepter
- type LoadBalance
- type Param
- type Params
- type PluginType
- type QPSCount
- type RoundRobin
- type SimpleDispatch
- type TagLoadBalance
Constants ¶
View Source
const Cluster_Static = "-" //静态资源
View Source
const Cluster_This = "." //本地插件
Variables ¶
This section is empty.
Functions ¶
func GetRealClientIP ¶
func GetRealClientIP(ctx *fasthttp.RequestCtx) string
func GetRuntimeContext ¶
func PathExists ¶
func SetAccessLogger ¶
func SetAccessLogger(log core.AccessLogger)
Types ¶
type AccessLogIntercepter ¶
type AccessLogIntercepter struct { BaseIntercepter // contains filtered or unexported fields }
访问日志
func (*AccessLogIntercepter) Before ¶
func (this *AccessLogIntercepter) Before(api *meta.Api, ctx *fasthttp.RequestCtx) (bool, error)
type AuthIntercepter ¶
type AuthIntercepter struct {
BaseIntercepter
}
鉴权拦截器
func (*AuthIntercepter) Before ¶
func (this *AuthIntercepter) Before(api *meta.Api, ctx *fasthttp.RequestCtx) (bool, error)
type BaseIntercepter ¶
type BaseIntercepter struct { }
抽象拦截器
func (*BaseIntercepter) Before ¶
func (this *BaseIntercepter) Before(api *meta.Api, ctx *fasthttp.RequestCtx) (bool, error)
func (*BaseIntercepter) Release ¶
func (this *BaseIntercepter) Release(api *meta.Api, ctx *fasthttp.RequestCtx) (bool, error)
type CiruitStatus ¶
type CiruitStatus byte
const ( CS_OPEN CiruitStatus = 2 //熔断打开 CS_CLOSE CiruitStatus = 0 //熔断关闭 CS_HALF CiruitStatus = 1 //熔断半打开状态 )
type DispatchManager ¶
type DispatchManager struct {
// contains filtered or unexported fields
}
func (*DispatchManager) AddApi ¶
func (this *DispatchManager) AddApi(domain, clusterName string, api *meta.Api)
新增api
func (*DispatchManager) AddCluster ¶
func (this *DispatchManager) AddCluster(cluster *meta.ServerCluster)
新增集群
func (*DispatchManager) AddServer ¶
func (this *DispatchManager) AddServer(clusterName string, server *meta.Server)
新增服务器
func (*DispatchManager) DelServer ¶
func (this *DispatchManager) DelServer(clusterName string, id int64)
删除服务器
func (*DispatchManager) GetApi ¶
func (this *DispatchManager) GetApi(domain, url string) *meta.Api
根据域名和url获取对应的API
func (*DispatchManager) GetCluster ¶
func (this *DispatchManager) GetCluster(name string) *meta.ServerCluster
获取集群
func (*DispatchManager) Init ¶
func (this *DispatchManager) Init()
type FastHTTPClient ¶
FastHTTPClient fast http client
func NewFastHTTPClient ¶
func NewFastHTTPClient() *FastHTTPClient
NewFastHTTPClient create FastHTTPClient instance
func NewFastHTTPClientOption ¶
func NewFastHTTPClientOption(defaultOption *HTTPOption) *FastHTTPClient
NewFastHTTPClientOption create FastHTTPClient instance with default option
func (*FastHTTPClient) Do ¶
func (c *FastHTTPClient) Do(req *fasthttp.Request, addr string, option *HTTPOption) (*fasthttp.Response, error)
Do do a http request
type HTTPOption ¶
type HTTPOption struct { // Maximum number of connections which may be established to server MaxConns int // MaxConnDuration Keep-alive connections are closed after this duration. MaxConnDuration time.Duration // MaxIdleConnDuration Idle keep-alive connections are closed after this duration. MaxIdleConnDuration time.Duration // ReadBufferSize Per-connection buffer size for responses' reading. ReadBufferSize int // WriteBufferSize Per-connection buffer size for requests' writing. WriteBufferSize int // ReadTimeout Maximum duration for full response reading (including body). ReadTimeout time.Duration // WriteTimeout Maximum duration for full request writing (including body). WriteTimeout time.Duration // MaxResponseBodySize Maximum response body size. MaxResponseBodySize int }
HTTPOption http client option
func DefaultHTTPOption ¶
func DefaultHTTPOption() *HTTPOption
DefaultHTTPOption returns a HTTP Option
type HttpConfig ¶
type HttpProxy ¶
type HttpProxy struct {
// contains filtered or unexported fields
}
基本的代理
func (*HttpProxy) AddIntercepter ¶
func (this *HttpProxy) AddIntercepter(i Intercepter)
func (*HttpProxy) AddPlugin ¶
func (this *HttpProxy) AddPlugin(name string, plugin HandlePlugin)
func (*HttpProxy) Init ¶
func (this *HttpProxy) Init(dispatch *DispatchManager)
func (*HttpProxy) ServeHTTP ¶
func (this *HttpProxy) ServeHTTP(ctx *fasthttp.RequestCtx)
type IPHash ¶
type IPHash struct {
// contains filtered or unexported fields
}
*
ip hash loadbalance
type Intercepter ¶
type LimitIntercepter ¶
type LimitIntercepter struct {
BaseIntercepter
}
限流拦截器
func (*LimitIntercepter) Before ¶
func (this *LimitIntercepter) Before(api *meta.Api, ctx *fasthttp.RequestCtx) (bool, error)
type LoadBalance ¶
type LoadBalance interface { Config(p string) Select(req *fasthttp.RequestCtx, servers *[]*meta.Server) *meta.Server }
负载均衡器
func NewRoundRobin ¶
func NewRoundRobin() LoadBalance
type Params ¶
type Params []Param
Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.
type PluginType ¶
type PluginType byte
const ( PT_Balance PluginType = 10 //负载均衡插件类型 PT_Handle PluginType = 11 //内部服务插件 )
func ParsePluginType ¶
func ParsePluginType(pt string) PluginType
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
*
随机均衡负载器
func (RoundRobin) Select ¶
func (rr RoundRobin) Select(req *fasthttp.RequestCtx, servers *[]*meta.Server) *meta.Server
Select select a server from servers using RoundRobin
type SimpleDispatch ¶
type SimpleDispatch struct {
// contains filtered or unexported fields
}
*
dispatch
func (*SimpleDispatch) AddUrl ¶
func (this *SimpleDispatch) AddUrl(url string, handle interface{})
func (*SimpleDispatch) GetUrl ¶
func (this *SimpleDispatch) GetUrl(url string) interface{}
func (*SimpleDispatch) Init ¶
func (this *SimpleDispatch) Init()
type TagLoadBalance ¶
type TagLoadBalance struct { Tag string //tag // contains filtered or unexported fields }
根据标签进行处理
func (*TagLoadBalance) Config ¶
func (this *TagLoadBalance) Config(p string)
func (*TagLoadBalance) Select ¶
func (this *TagLoadBalance) Select(req *fasthttp.RequestCtx, servers *[]*meta.Server) *meta.Server
Click to show internal directories.
Click to hide internal directories.