Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DrpcRegistryDiscovery ¶
type DrpcRegistryDiscovery struct { *MultiServerDiscovery // contains filtered or unexported fields }
func NewDrpcRegistryDiscovery ¶
func NewDrpcRegistryDiscovery(registry string, timeout time.Duration) *DrpcRegistryDiscovery
NewDrpcRegistryDiscovery do
func (*DrpcRegistryDiscovery) Get ¶
func (dr *DrpcRegistryDiscovery) Get(mode SelectMode) (string, error)
Get 和 GetAll 与 MultiServersDiscovery 相似, 唯一的不同在于,GeeRegistryDiscovery 需要先调用 Refresh 确保服务列表没有过期。
func (*DrpcRegistryDiscovery) GetAll ¶
func (dr *DrpcRegistryDiscovery) GetAll() ([]string, error)
func (*DrpcRegistryDiscovery) Update ¶
func (dr *DrpcRegistryDiscovery) Update(servers []string) error
Update update server list
type MultiServerDiscovery ¶
type MultiServerDiscovery struct {
// contains filtered or unexported fields
}
func NewMultiServerDiscovery ¶
func NewMultiServerDiscovery(servers []string) *MultiServerDiscovery
func (*MultiServerDiscovery) Get ¶
func (d *MultiServerDiscovery) Get(mode SelectMode) (string, error)
Get gets a server by mode
func (*MultiServerDiscovery) GetAll ¶
func (d *MultiServerDiscovery) GetAll() ([]string, error)
GetAll return all the servers in discovery
func (*MultiServerDiscovery) Refresh ¶
func (d *MultiServerDiscovery) Refresh() error
Refresh do what???
func (*MultiServerDiscovery) Update ¶
func (d *MultiServerDiscovery) Update(servers []string) error
Update updates the servers of discovery dynamically if necessary
type SelectMode ¶
type SelectMode int
const ( RandomSelect SelectMode = iota // select randomly RoundRobinSelect // select using Robbin algorithm )
type XClient ¶
type XClient struct {
// contains filtered or unexported fields
}
XClient is a client that supports load balance
func NewXClient ¶
func NewXClient(d Discovery, mode SelectMode, opt *Option) *XClient
NewXClient 的构造函数需要传入三个参数, * 服务发现实例 Discovery * 负载均衡模式 SelectMode * 协议选项 Option 为了尽量地复用已经创建好的 Socket 连接,使用 clients 保存创建成功的 Client 实例, 并提供 Close 方法。用于在结束后,关闭已经建立的所有连接
func (*XClient) BroadCast ¶
func (xc *XClient) BroadCast(ctx context.Context, serviceMethod string, args, ret interface{}) error
BroadCast invokes the named function for every server registered in discovery
Click to show internal directories.
Click to hide internal directories.