Documentation ¶
Index ¶
- func GetServerById(serverId string, args ...bool) *treaty.Server
- func GetServerByType(serverType, serverArg string, args ...bool) *treaty.Server
- func GetServerByTypeLoad(serverType string, args ...bool) *treaty.Server
- func GetServerList(args ...bool) map[string]*treaty.Server
- func GetServerTypeList(serverType string, args ...bool) map[string]*treaty.Server
- func InitDiscoverer(cfg config.DiscoverConf)
- func RegEventHandlers(handlers ...EventHandler)
- func Register(server *treaty.Server) error
- func UnRegister(server *treaty.Server) error
- type Discoverer
- type EtcdDiscoverer
- func (e *EtcdDiscoverer) DumpServers()
- func (e *EtcdDiscoverer) EventHandlerExec(ev *clientv3.Event, server *treaty.Server)
- func (e *EtcdDiscoverer) FindServer(serverType string) []*treaty.Server
- func (e *EtcdDiscoverer) FindServerList() map[string][]*treaty.Server
- func (e *EtcdDiscoverer) GetServerById(serverId string, args ...bool) *treaty.Server
- func (e *EtcdDiscoverer) GetServerByType(serverType, serverArg string, args ...bool) *treaty.Server
- func (e *EtcdDiscoverer) GetServerByTypeLoad(serverType string, args ...bool) *treaty.Server
- func (e *EtcdDiscoverer) GetServerList(args ...bool) map[string]*treaty.Server
- func (e *EtcdDiscoverer) GetServerTypeList(serverType string, args ...bool) map[string]*treaty.Server
- func (e *EtcdDiscoverer) Init()
- func (e *EtcdDiscoverer) IsCurEvent(key string) bool
- func (e *EtcdDiscoverer) RegEventHandlers(handlers ...EventHandler)
- func (e *EtcdDiscoverer) Register(server *treaty.Server) error
- func (e *EtcdDiscoverer) UnRegister(server *treaty.Server) error
- func (e *EtcdDiscoverer) Watcher()
- type EtcdOption
- type EventHandler
- type Finder
- func (f *Finder) GetServerCache(serverType string, arg any) *treaty.Server
- func (f *Finder) GetServerDiscover(serverType string, arg any) *treaty.Server
- func (f *Finder) GetUserServer(serverType string, arg any) *treaty.Server
- func (f *Finder) RemoveUserCache(arg any)
- func (f *Finder) ServerEventHandler(ev *clientv3.Event, server *treaty.Server)
- type Findkey
- type ServerMap
- type ServerTypeItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetServerByType ¶
func GetServerByTypeLoad ¶ added in v2.0.3
func GetServerTypeList ¶
func InitDiscoverer ¶
func InitDiscoverer(cfg config.DiscoverConf)
func RegEventHandlers ¶
func RegEventHandlers(handlers ...EventHandler)
func UnRegister ¶
Types ¶
type Discoverer ¶
type Discoverer interface { Register(server *treaty.Server) error //注册服务器 UnRegister(server *treaty.Server) error //注册服务器 GetServerList(args ...bool) map[string]*treaty.Server //获取所有服务信息 GetServerById(serverId string, args ...bool) *treaty.Server //根据serverId获取server信息 GetServerByType(serverType, serverArg string, args ...bool) *treaty.Server //根据serverType及参数分配唯一server信息 GetServerByTypeLoad(serverType string, args ...bool) *treaty.Server //根绝服务器最小负载量选择服务 GetServerTypeList(serverType string, args ...bool) map[string]*treaty.Server RegEventHandlers(handlers ...EventHandler) EventHandlerExec(ev *clientv3.Event, server *treaty.Server) }
Discoverer find service role
type EtcdDiscoverer ¶
type EtcdDiscoverer struct { Config clientv3.Config Client *clientv3.Client ServerList map[string]*treaty.Server //serverId=>server ServerTypeMap map[string]*ServerTypeItem //serverType=>serverTypeItem ServerLock *sync.RWMutex EventHandlerList []EventHandler Prefix string }
EtcdDiscoverer etcd discoverer
func NewEtcdDiscoverer ¶
func NewEtcdDiscoverer(opts ...EtcdOption) *EtcdDiscoverer
NewEtcdDiscoverer init EtcdDiscoverer
func (*EtcdDiscoverer) DumpServers ¶
func (e *EtcdDiscoverer) DumpServers()
func (*EtcdDiscoverer) EventHandlerExec ¶
func (e *EtcdDiscoverer) EventHandlerExec(ev *clientv3.Event, server *treaty.Server)
func (*EtcdDiscoverer) FindServer ¶
func (e *EtcdDiscoverer) FindServer(serverType string) []*treaty.Server
func (*EtcdDiscoverer) FindServerList ¶
func (e *EtcdDiscoverer) FindServerList() map[string][]*treaty.Server
func (*EtcdDiscoverer) GetServerById ¶
func (e *EtcdDiscoverer) GetServerById(serverId string, args ...bool) *treaty.Server
func (*EtcdDiscoverer) GetServerByType ¶
func (e *EtcdDiscoverer) GetServerByType(serverType, serverArg string, args ...bool) *treaty.Server
func (*EtcdDiscoverer) GetServerByTypeLoad ¶ added in v2.0.3
func (e *EtcdDiscoverer) GetServerByTypeLoad(serverType string, args ...bool) *treaty.Server
func (*EtcdDiscoverer) GetServerList ¶
func (e *EtcdDiscoverer) GetServerList(args ...bool) map[string]*treaty.Server
func (*EtcdDiscoverer) GetServerTypeList ¶
func (*EtcdDiscoverer) IsCurEvent ¶
func (e *EtcdDiscoverer) IsCurEvent(key string) bool
func (*EtcdDiscoverer) RegEventHandlers ¶
func (e *EtcdDiscoverer) RegEventHandlers(handlers ...EventHandler)
func (*EtcdDiscoverer) Register ¶
func (e *EtcdDiscoverer) Register(server *treaty.Server) error
Register register
func (*EtcdDiscoverer) UnRegister ¶
func (e *EtcdDiscoverer) UnRegister(server *treaty.Server) error
func (*EtcdDiscoverer) Watcher ¶
func (e *EtcdDiscoverer) Watcher()
type EtcdOption ¶
type EtcdOption func(e *EtcdDiscoverer)
func WithEtcdDialTimeOut ¶
func WithEtcdDialTimeOut(d time.Duration) EtcdOption
func WithEtcdEndpoints ¶
func WithEtcdEndpoints(endpoints []string) EtcdOption
func WithEtcdPrefix ¶
func WithEtcdPrefix(prefix string) EtcdOption
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
func (*Finder) GetServerCache ¶
func (*Finder) GetServerDiscover ¶
func (*Finder) GetUserServer ¶
func (*Finder) RemoveUserCache ¶
type ServerTypeItem ¶
type ServerTypeItem struct { List map[string]*treaty.Server // contains filtered or unexported fields }
func NewServerTypeItem ¶
func NewServerTypeItem() *ServerTypeItem
Click to show internal directories.
Click to hide internal directories.