endpoint

package
v0.0.0-...-c037550 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusGreen = iota
	StatusBlue
	StatusYellow
	StatusOrange
	StatusRed
)

Variables

This section is empty.

Functions

func GenRandomNumbers

func GenRandomNumbers(begin int, end int, count int) []int

Types

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

func NewEndpoint

func NewEndpoint(cluster cluster.Cluster) *Endpoint

func (*Endpoint) Evict

func (e *Endpoint) Evict(name string, ip string, port int)

evict action

func (*Endpoint) Fetch

func (e *Endpoint) Fetch(name string, n int, fa FetchAlgorithm) ([]Registry, error)

fetch registry

func (*Endpoint) Recv

func (e *Endpoint) Recv(transInfo TransInfo) error

func (*Endpoint) Register

func (e *Endpoint) Register(name string, ip string, port int, weight int, extra map[string]interface{})

register action

func (*Endpoint) RegistryDetail

func (e *Endpoint) RegistryDetail(name string) []Registry

registry detail

func (*Endpoint) RegistryList

func (e *Endpoint) RegistryList() []string

registry name list

func (*Endpoint) RegistrySummary

func (e *Endpoint) RegistrySummary() map[string]int

registry summary

func (*Endpoint) Stop

func (e *Endpoint) Stop()

type FetchAlgorithm

type FetchAlgorithm func(items ItemList, n int) []Item

type Item

type Item struct {
	Score int
	Data  interface{}
}

func FetchMaxN

func FetchMaxN(items ItemList, n int) []Item

func FetchMinN

func FetchMinN(items ItemList, n int) []Item

func FetchRandomN

func FetchRandomN(items ItemList, n int) []Item

type ItemList

type ItemList []Item

func (ItemList) Len

func (s ItemList) Len() int

func (ItemList) Less

func (s ItemList) Less(i, j int) bool

func (ItemList) Swap

func (s ItemList) Swap(i, j int)

type Registry

type Registry struct {
	Name     string                 `json:"name"`   //server name
	Ip       string                 `json:"ip"`     //server ip
	Port     int                    `json:"port"`   //server port
	Status   int                    `json:"status"` //server status
	CreateAt int64                  `json:"create_at"`
	UpdateAt int64                  `json:"update_at"`
	Weight   int                    `json:"weight"` //server weight(负载权重,负载均衡使用)
	Extra    map[string]interface{} `json:"extra"`  //其他数据
}

type SyncInfo

type SyncInfo struct {
	Action   string   `json:"action"`
	Registry Registry `json:"registry"`
}

type TransInfo

type TransInfo struct {
	Source string     `json:"source"`
	Data   []SyncInfo `json:"data"`
}

Jump to

Keyboard shortcuts

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