consul: Ensure clients also implement LocalMember

This commit is contained in:
Armon Dadgar 2014-05-29 11:21:56 -07:00
parent f9766541e1
commit 890d4d771f
2 changed files with 11 additions and 1 deletions

View File

@ -313,7 +313,11 @@ func (a *Agent) ForceLeave(node string) (err error) {
// LocalMember is used to return the local node
func (a *Agent) LocalMember() serf.Member {
return a.server.LocalMember()
if a.server != nil {
return a.server.LocalMember()
} else {
return a.client.LocalMember()
}
}
// LANMembers is used to retrieve the LAN members

View File

@ -31,6 +31,7 @@ const (
type Interface interface {
RPC(method string, args interface{}, reply interface{}) error
LANMembers() []serf.Member
LocalMember() serf.Member
}
// Client is Consul client which uses RPC to communicate with the
@ -181,6 +182,11 @@ func (c *Client) JoinLAN(addrs []string) (int, error) {
return c.serf.Join(addrs, true)
}
// LocalMember is used to return the local node
func (c *Client) LocalMember() serf.Member {
return c.serf.LocalMember()
}
// LANMembers is used to return the members of the LAN cluster
func (c *Client) LANMembers() []serf.Member {
return c.serf.Members()