dispatcher

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFoundRoute    = errors.New("not found route")
	ErrNotFoundEvent    = errors.New("not found event")
	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 Dispatcher

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

func NewDispatcher

func NewDispatcher(strategy BalanceStrategy) *Dispatcher

func (*Dispatcher) FindEndpoint

func (d *Dispatcher) FindEndpoint(insID string) (*endpoint.Endpoint, error)

FindEndpoint 查找服务端口

func (*Dispatcher) FindEvent

func (d *Dispatcher) FindEvent(event cluster.Event) (*Event, error)

FindEvent 查找节点事件

func (*Dispatcher) FindRoute

func (d *Dispatcher) FindRoute(route int32) (*Route, error)

FindRoute 查找节点路由

func (*Dispatcher) IterateEndpoint

func (d *Dispatcher) IterateEndpoint(fn func(insID string, ep *endpoint.Endpoint) bool)

IterateEndpoint 迭代服务端口

func (*Dispatcher) ReplaceServices

func (d *Dispatcher) ReplaceServices(services ...*registry.ServiceInstance)

ReplaceServices 替换服务

type Event

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

func (*Event) Event

func (e *Event) Event() cluster.Event

Event 获取事件

func (*Event) FindEndpoint

func (a *Event) FindEndpoint(insID ...string) (*endpoint.Endpoint, error)

FindEndpoint 查询路由服务端点

type Route

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

func (*Route) FindEndpoint

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

FindEndpoint 查询路由服务端点

func (*Route) ID

func (r *Route) ID() int32

ID 获取路由ID

func (*Route) Stateful

func (r *Route) Stateful() bool

Stateful 获取路由状态

Jump to

Keyboard shortcuts

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