Documentation ¶
Index ¶
- type Consul
- func (p *Consul) GetServers() (servers map[string]*Server, err error)
- func (p *Consul) RegisterService(server *Server, ttl string) (err error)
- func (p *Consul) UnRegisterService(serverId string) (err error)
- func (p *Consul) UpdateServerTTL(server *Server, status string) (err error)
- func (p *Consul) WatchServer(ServersChanged)
- type Discoverer
- type Etcd
- func (p *Etcd) GetServers() (servers map[string]*Server, err error)
- func (p *Etcd) RegisterService(server *Server) (leaseId string, err error)
- func (p *Etcd) UnRegisterService(serverId string) (err error)
- func (p *Etcd) UpdateServerTTL(leaseId string) (err error)
- func (p *Etcd) WatchServer(fun ServersChanged)
- type Server
- type ServerChange
- type ServersChanged
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consul ¶
type Consul struct {
// contains filtered or unexported fields
}
func (*Consul) RegisterService ¶
func (*Consul) UnRegisterService ¶
func (*Consul) UpdateServerTTL ¶
func (*Consul) WatchServer ¶
func (p *Consul) WatchServer(ServersChanged)
type Discoverer ¶
type Discoverer interface { GetServers() (servers map[string]*Server, err error) // 通知服务改变(下线,上线). 在第一次watch会一次性收到当前所有在线的服务上线通知 WatchServer(ServersChanged) // 刷新存活时间 UpdateServerTTL(leaseId string) (err error) RegisterService(server *Server) (leaseId string, err error) UnRegisterService(serverId string) (err error) }
func NewEtcd ¶
func NewEtcd(etcdEndpoints []string, ttl int64) Discoverer
type Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
func (*Etcd) RegisterService ¶
func (*Etcd) UnRegisterService ¶
func (*Etcd) UpdateServerTTL ¶
func (*Etcd) WatchServer ¶
func (p *Etcd) WatchServer(fun ServersChanged)
type ServerChange ¶
type ServerChange int8
const ( SC_Online ServerChange = iota + 1 SC_Offline )
func (ServerChange) String ¶
func (s ServerChange) String() string
type ServersChanged ¶
type ServersChanged func(server *Server, change ServerChange)
Click to show internal directories.
Click to hide internal directories.