slbKit

package
v3.0.919 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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 后端服务是否可用?

func (*Backend) IsAlive

func (be *Backend) IsAlive() (alive bool)

func (*Backend) SetAlive added in v3.0.918

func (be *Backend) SetAlive(alive bool)

type LoadBalancer

type LoadBalancer struct {
	mutexKit.RWMutex
	// contains filtered or unexported fields
}

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: 此方法无需加锁.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL