Documentation ¶
Index ¶
- Constants
- Variables
- func AllNodes() ([]*memberlist.Node, error)
- func CallbackOnChange(listener *memConfigListener) func(event *configmgr.NacosChangeEvent)
- func Leave(timeout time.Duration)
- func LocalNode() *memberlist.Node
- func NewGrpc(data ...map[string]interface{})
- func NewGrpcClientConn(service string, lb string, dialOptions ...grpc.DialOption) *grpc.ClientConn
- func NewRRGrpcClientConn(service string, dialOptions ...grpc.DialOption) *grpc.ClientConn
- func NewRest(data ...map[string]interface{})
- func NewSWRRGrpcClientConn(service string, dialOptions ...grpc.DialOption) *grpc.ClientConn
- func RegisterServiceProvider(sp IMemberlistServiceProvider)
- func Shutdown()
- type Chooser
- type IMemberlistServiceProvider
- type NodeMeta
- type RRServiceProvider
- type SWRRServiceProvider
- type Service
- type WeightAddrInfo
- type WeightAttributeKey
Constants ¶
const Name = "memberlist_weight_balancer"
Variables ¶
var BroadcastQueue *memberlist.TransmitLimitedQueue
Functions ¶
func AllNodes ¶
func AllNodes() ([]*memberlist.Node, error)
AllNodes return all memberlist nodes except dead and left nodes
func CallbackOnChange ¶
func CallbackOnChange(listener *memConfigListener) func(event *configmgr.NacosChangeEvent)
func LocalNode ¶
func LocalNode() *memberlist.Node
func NewGrpcClientConn ¶
func NewGrpcClientConn(service string, lb string, dialOptions ...grpc.DialOption) *grpc.ClientConn
func NewRRGrpcClientConn ¶
func NewRRGrpcClientConn(service string, dialOptions ...grpc.DialOption) *grpc.ClientConn
func NewSWRRGrpcClientConn ¶
func NewSWRRGrpcClientConn(service string, dialOptions ...grpc.DialOption) *grpc.ClientConn
func RegisterServiceProvider ¶
func RegisterServiceProvider(sp IMemberlistServiceProvider)
Types ¶
type Chooser ¶
type Chooser struct {
// contains filtered or unexported fields
}
Chooser from naming_client package in nacos-sdk-go
type IMemberlistServiceProvider ¶
type IMemberlistServiceProvider interface { AddNode(node *memberlist.Node) UpdateWeight(node *memberlist.Node) RemoveNode(node *memberlist.Node) }
IMemberlistServiceProvider defines service provider interface for server discovery
type NodeMeta ¶
type RRServiceProvider ¶
type RRServiceProvider struct {
// contains filtered or unexported fields
}
RRServiceProvider defines an implementation for IMemberlistServiceProvider
func NewRRServiceProvider ¶
func NewRRServiceProvider(name string) *RRServiceProvider
NewRRServiceProvider create an RRServiceProvider instance
func (*RRServiceProvider) AddNode ¶
func (m *RRServiceProvider) AddNode(node *memberlist.Node)
func (*RRServiceProvider) Close ¶ added in v2.0.6
func (m *RRServiceProvider) Close()
func (*RRServiceProvider) RemoveNode ¶
func (m *RRServiceProvider) RemoveNode(node *memberlist.Node)
func (*RRServiceProvider) SelectServer ¶
func (m *RRServiceProvider) SelectServer() string
SelectServer selects a node which is supplying service specified by name property from cluster
func (*RRServiceProvider) UpdateWeight ¶
func (m *RRServiceProvider) UpdateWeight(node *memberlist.Node)
type SWRRServiceProvider ¶
type SWRRServiceProvider struct {
// contains filtered or unexported fields
}
SWRRServiceProvider is a smooth weighted round-robin algo implementation for IMemberlistServiceProvider https://github.com/nginx/nginx/commit/52327e0627f49dbda1e8db695e63a4b0af4448b1
func NewSWRRServiceProvider ¶
func NewSWRRServiceProvider(name string) *SWRRServiceProvider
NewSWRRServiceProvider create an SWRRServiceProvider instance
func (*SWRRServiceProvider) AddNode ¶
func (m *SWRRServiceProvider) AddNode(node *memberlist.Node)
func (*SWRRServiceProvider) Close ¶ added in v2.0.6
func (m *SWRRServiceProvider) Close()
func (*SWRRServiceProvider) RemoveNode ¶
func (m *SWRRServiceProvider) RemoveNode(node *memberlist.Node)
func (*SWRRServiceProvider) SelectServer ¶
func (m *SWRRServiceProvider) SelectServer() string
SelectServer selects a node which is supplying service specified by name property from cluster
func (*SWRRServiceProvider) UpdateWeight ¶
func (m *SWRRServiceProvider) UpdateWeight(node *memberlist.Node)
type Service ¶
type WeightAddrInfo ¶
type WeightAddrInfo struct {
Weight int
}
type WeightAttributeKey ¶
type WeightAttributeKey struct{}