loadbalancer

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseInstance

func ChooseInstance(ctx model.ValueContext, loadbalancer LoadBalancer,
	criteria *Criteria, instances model.ServiceInstances) (model.Instance, model.SDKError)

ChooseInstance 执行负载均衡

Types

type Criteria

type Criteria struct {
	// 用户传入用于计算hash的二进制流
	HashKey []byte
	// 用户传入用于计算hash的int值
	HashValue uint64
	// 分配时忽略半开实例,只有当没有其他节点时才分配半开节点
	IgnoreHalfOpen bool
	// 必选,目标cluster
	Cluster *model.Cluster
	// 可选,对于有状态的负载均衡方式,这里给出备份节点的返回数据
	ReplicateInfo ReplicateInfo
}

Criteria 负载均衡的过滤值成员

type LoadBalancer

type LoadBalancer interface {
	plugin.Plugin
	// ChooseInstance 进行负载均衡,选择一个实例
	ChooseInstance(criteria *Criteria, instances model.ServiceInstances) (model.Instance, error)
}

LoadBalancer 【扩展点接口】负载均衡

type Proxy

type Proxy struct {
	LoadBalancer
	// contains filtered or unexported fields
}

Proxy of LoadBalancer

func (*Proxy) ChooseInstance

func (p *Proxy) ChooseInstance(criteria *Criteria, instances model.ServiceInstances) (model.Instance, error)

ChooseInstance proxy LoadBalancer ChooseInstance

func (*Proxy) SetRealPlugin

func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine)

SetRealPlugin 设置

type ReplicateInfo

type ReplicateInfo struct {
	Count int
	Nodes []model.Instance
}

ReplicateInfo 备份节点信息

type SelectStatus

type SelectStatus struct {
	HasLimitedInstances bool
	IncludeHalfOpen     bool
}

SelectStatus 获取负载均衡状态

Jump to

Keyboard shortcuts

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