Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConsistentHash ¶
type ConsistentHash struct {
// contains filtered or unexported fields
}
ConsistentHash defines the consistent hash.
func NewConsistentHash ¶
func NewConsistentHash() *ConsistentHash
NewConsistentHash creates a new ConsistentHash.
type Node ¶
type Node struct { ServiceName string // 服务名 ContainerName string // 容器名 Address string // 目标地址 ip:port Network string // 网络层协议 tcp/udp Protocol string // 业务协议 trpc/http SetName string // 节点Set名 Weight int // 权重 CostTime time.Duration // 当次请求耗时 EnvKey string // 透传的环境信息 Metadata map[string]interface{} }
Node is the information of a node.
type Option ¶
type Option func(*Options)
Option modifies the Options.
func WithContext ¶
WithContext returns an Option which set request ctx.
func WithInterval ¶
WithInterval returns an Option which set load balance refresh interval.
func WithLoadBalanceType ¶
WithLoadBalanceType returns an Option which set load balance type.
func WithNamespace ¶
WithNamespace returns an Option which set namespace.
func WithReplicas ¶
WithReplicas returns an Option which set the virtual node coefficient.
type Options ¶
type Options struct { Ctx context.Context // request context Interval time.Duration // refresh interval Namespace string // namespace LoadBalanceType string // load balance type Replicas int // virtual node coefficient of consistent hash }
Options is the call options.
type UInt32Slice ¶
type UInt32Slice []uint32
UInt32Slice defines uint32 slice.
func (UInt32Slice) Less ¶
func (s UInt32Slice) Less(i, j int) bool
Less returns whether the value at i is less than j.
Click to show internal directories.
Click to hide internal directories.