Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEndpointAlreadyExists 网关端点已存在 ErrEndpointAlreadyExists = errors.New("gateway: endpoint already exists") // ErrCannotAddRunningEndpoint 无法添加一个正在运行的网关端点 ErrCannotAddRunningEndpoint = errors.New("gateway: cannot add a running endpoint") // ErrEndpointNotExists 该名称下不存在任何端点 ErrEndpointNotExists = errors.New("gateway: endpoint not exists") )
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint 网关端点
func NewEndpoint ¶
func NewEndpoint(name, address string, options ...EndpointOption) *Endpoint
NewEndpoint 创建网关端点
type EndpointManager ¶
type EndpointManager struct {
// contains filtered or unexported fields
}
EndpointManager 网关端点管理器
func (*EndpointManager) AddEndpoint ¶
func (slf *EndpointManager) AddEndpoint(endpoint *Endpoint) error
AddEndpoint 添加端点
func (*EndpointManager) GetEndpoint ¶
GetEndpoint 获取端点
func (*EndpointManager) RemoveEndpoint ¶
func (slf *EndpointManager) RemoveEndpoint(endpoint *Endpoint) error
RemoveEndpoint 移除端点
type EndpointOption ¶ added in v0.0.30
type EndpointOption func(endpoint *Endpoint)
EndpointOption 网关端点选项
func WithEndpointStateEvaluator ¶ added in v0.0.30
func WithEndpointStateEvaluator(evaluator func(costUnixNano float64) float64) EndpointOption
WithEndpointStateEvaluator 设置端点健康值评估函数
type Gateway ¶
type Gateway struct { *EndpointManager // 端点管理器 // contains filtered or unexported fields }
Gateway 网关
func NewGateway ¶
NewGateway 基于 server.Server 创建网关服务器
type Option ¶
type Option func(gateway *Gateway)
Option 网关选项
func WithEndpointSelector ¶
WithEndpointSelector 设置端点选择器
- 默认情况下,网关会随机选择一个端点作为目标,如果需要自定义端点选择器,可以通过该选项设置
Click to show internal directories.
Click to hide internal directories.