discovery

package
v0.0.0-...-3b54ddd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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) GetServers

func (p *Consul) GetServers() (servers map[string]*Server, err error)

func (*Consul) RegisterService

func (p *Consul) RegisterService(server *Server, ttl string) (err error)

func (*Consul) UnRegisterService

func (p *Consul) UnRegisterService(serverId string) (err error)

func (*Consul) UpdateServerTTL

func (p *Consul) UpdateServerTTL(server *Server, status string) (err error)

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) GetServers

func (p *Etcd) GetServers() (servers map[string]*Server, err error)

func (*Etcd) RegisterService

func (p *Etcd) RegisterService(server *Server) (leaseId string, err error)

func (*Etcd) UnRegisterService

func (p *Etcd) UnRegisterService(serverId string) (err error)

func (*Etcd) UpdateServerTTL

func (p *Etcd) UpdateServerTTL(leaseId string) (err error)

func (*Etcd) WatchServer

func (p *Etcd) WatchServer(fun ServersChanged)

type Server

type Server struct {
	Id      string
	Name    string
	Address string
	Port    int
	Extends map[string]interface{}
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL