Distrabution

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBackendToRegistry

func AddBackendToRegistry(registryAddr string, servername string, backendUrl *url.URL)

AddBackendToRegistry调用rpc注册接口

func CheckBackendHealth

func CheckBackendHealth()

CheckBackendHealth检查服务提供者的健康

func LB

func LB(w http.ResponseWriter, r *http.Request)

LB 对入向请求进行负载均衡

func RegistBackend

func RegistBackend(serverAddr string, serverName string, registryAddr string)

RegistBackend提供注册接口

func ServerPoolInit

func ServerPoolInit()

ServerPoolInit初始化服务提供者集合

Types

type AddBackEndArgs

type AddBackEndArgs struct {
	Name string
	URL  *url.URL
}

AddBackEndArgs 添加后端参数

type AddServerI

type AddServerI struct {
}

func (*AddServerI) AddBackEnd

func (s *AddServerI) AddBackEnd(args AddBackEndArgs, reply *int) error

AddBackEnd添加后端

type Backend

type Backend struct {
	URL   *url.URL
	Alive bool

	ReverseProxy *httputil.ReverseProxy
	// contains filtered or unexported fields
}

Backend服务提供者

func GetNextPeer

func GetNextPeer(name string) *Backend

GetNextPeer返回下一个可用的服务器

func (*Backend) IsAlive

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

如果后端还活着,IsAlive 返回 true

func (*Backend) SetAlive

func (b *Backend) SetAlive(alive bool)

SetAlive修改存活状态

type ServerPool

type ServerPool struct {
	ServerNameBackendsMap map[string][]*Backend
	ServerNameNextIndex   map[string]int
}

ServerPool服务提供者集合

var SP ServerPool

Jump to

Keyboard shortcuts

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