memberlist

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "memberlist_weight_balancer"

Variables

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 Leave

func Leave(timeout time.Duration)

Leave leaves the cluster on purpose

func LocalNode

func LocalNode() *memberlist.Node

func NewGrpc

func NewGrpc(data ...map[string]interface{})

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 NewRest

func NewRest(data ...map[string]interface{})

func NewSWRRGrpcClientConn

func NewSWRRGrpcClientConn(service string, dialOptions ...grpc.DialOption) *grpc.ClientConn

func RegisterServiceProvider

func RegisterServiceProvider(sp IMemberlistServiceProvider)

func Shutdown

func Shutdown()

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 NodeMeta struct {
	Services   []Service  `json:"serviceInfo"`
	RegisterAt *time.Time `json:"registerAt"`
	GoVer      string     `json:"goVer"`
	GddVer     string     `json:"gddVer"`
	BuildUser  string     `json:"buildUser"`
	BuildTime  string     `json:"buildTime"`
	Weight     int        `json:"weight"`
}

func ParseMeta

func ParseMeta(node *memberlist.Node) (NodeMeta, error)

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 Service struct {
	Name          string                 `json:"name"`
	Host          string                 `json:"host"`
	Port          int                    `json:"port"`
	RouteRootPath string                 `json:"routeRootPath"`
	Type          constants.ServiceType  `json:"type"`
	Data          map[string]interface{} `json:"data,omitempty"`
}

func (*Service) BaseUrl

func (receiver *Service) BaseUrl() string

type WeightAddrInfo

type WeightAddrInfo struct {
	Weight int
}

type WeightAttributeKey

type WeightAttributeKey struct{}

Jump to

Keyboard shortcuts

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