Documentation ¶
Index ¶
- func GetServerById(serverId string) *treaty.Server
- func GetServerByType(serverType, serverArg string) *treaty.Server
- func GetServerList() map[string]*treaty.Server
- func GetServerTypeList(serverType string) 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) *treaty.Server
- func (e *EtcdDiscoverer) GetServerByType(serverType, serverArg string) *treaty.Server
- func (e *EtcdDiscoverer) GetServerList() map[string]*treaty.Server
- func (e *EtcdDiscoverer) GetServerTypeList(serverType string) 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, userId int) *treaty.Server
- func (f *Finder) GetServerCache2(serverType string, arg string) *treaty.Server
- func (f *Finder) GetServerDiscover(serverType string, userId int) *treaty.Server
- func (f *Finder) GetServerDiscover2(serverType string, arg string) *treaty.Server
- func (f *Finder) GetUserServer(serverType string, userId int) *treaty.Server
- func (f *Finder) GetUserServer2(serverType string, arg string) *treaty.Server
- func (f *Finder) RemoveUserCache(userId int)
- func (f *Finder) RemoveUserCache2(arg string)
- func (f *Finder) ServerEventHandler(ev *clientv3.Event, server *treaty.Server)
- type ServerTypeItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetServerById ¶
func GetServerByType ¶
func GetServerList ¶
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() map[string]*treaty.Server //获取所有服务信息 GetServerById(serverId string) *treaty.Server //根据serverId获取server信息 GetServerByType(serverType, serverArg string) *treaty.Server //根据serverType及参数分配唯一server信息 GetServerTypeList(serverType string) 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) *treaty.Server
func (*EtcdDiscoverer) GetServerByType ¶
func (e *EtcdDiscoverer) GetServerByType(serverType, serverArg string) *treaty.Server
func (*EtcdDiscoverer) GetServerList ¶
func (e *EtcdDiscoverer) GetServerList() map[string]*treaty.Server
func (*EtcdDiscoverer) GetServerTypeList ¶
func (e *EtcdDiscoverer) GetServerTypeList(serverType string) map[string]*treaty.Server
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) GetServerCache2 ¶
func (*Finder) GetServerDiscover ¶
func (*Finder) GetServerDiscover2 ¶
func (*Finder) GetUserServer ¶
func (*Finder) GetUserServer2 ¶
func (*Finder) RemoveUserCache ¶
func (*Finder) RemoveUserCache2 ¶
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.