Documentation ¶
Index ¶
- type Backend
- type LoadBalancer
- func (lb *LoadBalancer) AddBackend(backend *Backend)
- func (lb *LoadBalancer) Dispose()
- func (lb *LoadBalancer) GetNextPeer() (backend *Backend)
- func (lb *LoadBalancer) HandleRequest(w http.ResponseWriter, r *http.Request) error
- func (lb *LoadBalancer) HealthCheck()
- func (lb *LoadBalancer) NextIndex() int32
- func (lb *LoadBalancer) Start() (err error)
- func (lb *LoadBalancer) UpdateIndex(i int32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct { mutexKit.Mutex // Alive 节点是否可用? Alive bool URL *url.URL ReverseProxy *httputil.ReverseProxy }
func (*Backend) HealthCheck ¶
func (be *Backend) HealthCheck()
HealthCheck 健康检查(此方法会修改 Alive 字段).
@return 后端服务是否可用?
type LoadBalancer ¶
func NewLoadBalancer ¶
func NewLoadBalancer() (lb *LoadBalancer)
func (*LoadBalancer) AddBackend ¶
func (lb *LoadBalancer) AddBackend(backend *Backend)
func (*LoadBalancer) Dispose ¶
func (lb *LoadBalancer) Dispose()
func (*LoadBalancer) GetNextPeer ¶ added in v3.0.918
func (lb *LoadBalancer) GetNextPeer() (backend *Backend)
GetNextPeer
@return 可能为nil(即此时无可用后端服务)
func (*LoadBalancer) HandleRequest ¶
func (lb *LoadBalancer) HandleRequest(w http.ResponseWriter, r *http.Request) error
func (*LoadBalancer) HealthCheck ¶ added in v3.0.918
func (lb *LoadBalancer) HealthCheck()
HealthCheck 对目前所有的后端服务,进行1次健康检查.
func (*LoadBalancer) NextIndex ¶ added in v3.0.918
func (lb *LoadBalancer) NextIndex() int32
NextIndex 返回下一个下标.
PS: (1) 此方法无需加锁; (2) 需要自行对返回值先进行 其余操作(%) 才能继续使用.
func (*LoadBalancer) Start ¶
func (lb *LoadBalancer) Start() (err error)
func (*LoadBalancer) UpdateIndex ¶ added in v3.0.918
func (lb *LoadBalancer) UpdateIndex(i int32)
UpdateIndex 更新下标.
PS: 此方法无需加锁.
Click to show internal directories.
Click to hide internal directories.