router

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFoundRoute    = errors.New("not found route")
	ErrNotFoundEndpoint = errors.New("not found endpoint")
)

Functions

This section is empty.

Types

type BalanceStrategy

type BalanceStrategy string
const (
	Random           BalanceStrategy = "random" // 随机
	RoundRobin       BalanceStrategy = "rr"     // 轮询
	WeightRoundRobin BalanceStrategy = "wrr"    // 加权轮询
)

type Route

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

func (*Route) FindEndpoint

func (r *Route) FindEndpoint(insID ...string) (*endpoint.Endpoint, error)

FindEndpoint 查询路由服务端点

func (*Route) Stateful

func (r *Route) Stateful() bool

Stateful 是否有状态

type Router

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

func NewRouter

func NewRouter(strategy BalanceStrategy) *Router

func (*Router) AddService

func (r *Router) AddService(service *registry.ServiceInstance) error

AddService 添加服务实例

func (*Router) AddServices

func (r *Router) AddServices(services ...*registry.ServiceInstance)

AddServices 添加服务实例

func (*Router) FindServiceEndpoint

func (r *Router) FindServiceEndpoint(insID string) (*endpoint.Endpoint, error)

FindServiceEndpoint 查找服务端口

func (*Router) FindServiceRoute

func (r *Router) FindServiceRoute(routeID int32) (*Route, error)

FindServiceRoute 查找节点路由

func (*Router) IterationServiceEndpoint

func (r *Router) IterationServiceEndpoint(fn func(insID string, ep *endpoint.Endpoint) bool)

IterationServiceEndpoint 迭代服务端口

func (*Router) RemoveServices

func (r *Router) RemoveServices(services ...*registry.ServiceInstance)

RemoveServices 移除服务实例

func (*Router) ReplaceServices

func (r *Router) ReplaceServices(services ...*registry.ServiceInstance)

ReplaceServices 替换服务实例

Jump to

Keyboard shortcuts

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