Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashString ¶
func NewPeerSelector ¶
Types ¶
type PeerSelector ¶
type PeerSelector struct {
// contains filtered or unexported fields
}
PeerSelector 点对点选择器
func (*PeerSelector) Select ¶
func (ms *PeerSelector) Select(ctx context.Context, servicePath, serviceMethod string, args interface{}) string
Select 根据context里的select_key选择匹配的服务器进行调用
func (*PeerSelector) UpdateServer ¶
func (ms *PeerSelector) UpdateServer(servers map[string]string)
UpdateServer 更新服务器
type Service ¶
type Service struct { ServiceName string // contains filtered or unexported fields }
func New ¶
func New(service string, etcdServerAddrs []string, callTimeout time.Duration, isPermanentSocketLink bool) *Service
New 创建对某个节点的rpc客户端管理结构 etcdServerAddrs:etcd服务的多个节点地址 callTimeout:调用服务超时时间 isPermanentSocketLink:默认跟rpc server不是永久连接,如果实时通讯量大的话,设置为true,
字段作用:如果跟server读超时就关闭socket连接,等待之后的请求重新connect, 用来避免长链接,有通信需求的双方节点形成强联通图,无用established套接字太多
func (*Service) Call ¶
func (s *Service) Call(ctx context.Context, method string, args interface{}, reply interface{}) error
Call 根据负载算法从服务中挑一个调用
func (*Service) CallAll ¶
func (s *Service) CallAll(ctx context.Context, method string, args interface{}, reply interface{}) error
CallAll 调用所有节点,有一个调用返回错误,整个调用都错误
func (*Service) SetSelector ¶
Click to show internal directories.
Click to hide internal directories.