Documentation ¶
Index ¶
- func NewPeerContext(ctx context.Context, p *Peer) context.Context
- func SetGlobalSelector(b Builder)
- type Builder
- type DefaultNode
- type DoneFunc
- type DoneInfo
- type Node
- type Peer
- type RandomBanlance
- type RandomBuilder
- type ReplyMD
- type RoundRobin
- type RoundRobinBuilder
- type Selector
- type WeightRandomBanlance
- type WeightRandomBuilder
- type WeightedRoundRobin
- type WeightedRoundRobinBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPeerContext ¶
NewPeerContext creates a new context with peer information attached.
func SetGlobalSelector ¶
func SetGlobalSelector(b Builder)
Types ¶
type Builder ¶
type Builder interface {
Build() Selector
}
func GlobalSelector ¶
func GlobalSelector() Builder
func NewRandomBuilder ¶
func NewRandomBuilder() Builder
func NewRoundRobinBuilder ¶
func NewRoundRobinBuilder() Builder
func NewWeightRandomBuilder ¶
func NewWeightRandomBuilder() Builder
func NewWeightedRoundRobinBuilder ¶
func NewWeightedRoundRobinBuilder() Builder
type DefaultNode ¶
type DefaultNode struct {
// contains filtered or unexported fields
}
func (*DefaultNode) InitialWeight ¶
func (n *DefaultNode) InitialWeight() int64
InitialWeight is node initialWeight
func (*DefaultNode) Metadata ¶
func (n *DefaultNode) Metadata() map[string]string
Metadata is node metadata
func (*DefaultNode) ServiceName ¶
func (n *DefaultNode) ServiceName() string
ServiceName is node serviceName
type Node ¶
type Node interface { // Address is the unique address under the same service Address() string // ServiceName is service name ServiceName() string // InitialWeight is the initial value of scheduling weight // if not set return nil InitialWeight() int64 // Version is service node version Version() string // Metadata is the kv pair metadata associated with the service instance. // version,namespace,region,protocol etc.. Metadata() map[string]string }
type Peer ¶
type Peer struct { // node is the peer node. Node Node }
Peer contains the information of the peer for an RPC, such as the address and authentication information.
type RandomBanlance ¶
type RandomBanlance struct {
// contains filtered or unexported fields
}
随机
func (*RandomBanlance) Add ¶
func (r *RandomBanlance) Add(nodes ...Node) error
func (*RandomBanlance) Build ¶
func (r *RandomBanlance) Build() Selector
type RandomBuilder ¶
type RandomBuilder struct {
// contains filtered or unexported fields
}
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
轮询
func (*RoundRobin) Add ¶
func (rr *RoundRobin) Add(nodes ...Node) error
type RoundRobinBuilder ¶
type RoundRobinBuilder struct {
// contains filtered or unexported fields
}
func (*RoundRobinBuilder) Build ¶
func (rr *RoundRobinBuilder) Build() Selector
type Selector ¶
type Selector interface { Add(nodes ...Node) error Next(ctx context.Context) (selected Node, err error) }
func NewRandomBanlance ¶
func NewRandomBanlance() Selector
func NewRoundRobin ¶
func NewRoundRobin() Selector
func NewWeightRandomBanlance ¶
func NewWeightRandomBanlance() Selector
type WeightRandomBanlance ¶
type WeightRandomBanlance struct {
// contains filtered or unexported fields
}
加权随机
func (*WeightRandomBanlance) Add ¶
func (wr *WeightRandomBanlance) Add(nodes ...Node) error
func (*WeightRandomBanlance) Build ¶
func (wr *WeightRandomBanlance) Build() Selector
type WeightRandomBuilder ¶
type WeightRandomBuilder struct {
// contains filtered or unexported fields
}
type WeightedRoundRobin ¶
type WeightedRoundRobin struct {
// contains filtered or unexported fields
}
func (*WeightedRoundRobin) Add ¶
func (w *WeightedRoundRobin) Add(nodes ...Node) error
*
- 添加所有的当前服务所有的节点
func (*WeightedRoundRobin) Build ¶
func (w *WeightedRoundRobin) Build() Selector
type WeightedRoundRobinBuilder ¶
type WeightedRoundRobinBuilder struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.