tiny cleanup
This commit is contained in:
@@ -351,24 +351,13 @@ func (p *SyncedPool) removeLocalGrain(id CartId) {
|
||||
delete(p.local.grains, id)
|
||||
}
|
||||
|
||||
func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) error {
|
||||
known := make([]string, 0, len(p.remotes)+1)
|
||||
|
||||
for _, r := range p.remotes {
|
||||
known = append(known, r.Host)
|
||||
if r.Host == address {
|
||||
log.Printf("Remote %s already exists\n", address)
|
||||
return fmt.Errorf("remote %s already exists", address)
|
||||
}
|
||||
}
|
||||
known = append([]string{p.Hostname}, known...)
|
||||
func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) {
|
||||
|
||||
p.remotes = append(p.remotes, remote)
|
||||
connectedRemotes.Set(float64(len(p.remotes)))
|
||||
log.Printf("Added remote %s\n", remote.Host)
|
||||
|
||||
go remote.Initialize(p)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) AddRemote(host string) error {
|
||||
@@ -380,12 +369,6 @@ func (p *SyncedPool) AddRemote(host string) error {
|
||||
log.Printf("Error connecting to remote %s: %v\n", host, err)
|
||||
return err
|
||||
}
|
||||
_, err = client.Call(Ping, Pong, []byte{})
|
||||
|
||||
if err != nil {
|
||||
log.Printf("No response from new remote %s", host)
|
||||
return err
|
||||
}
|
||||
|
||||
remote := RemoteHost{
|
||||
Client: client,
|
||||
@@ -404,10 +387,10 @@ func (p *SyncedPool) AddRemote(host string) error {
|
||||
for err != nil {
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
err = remote.Ping()
|
||||
if remote.MissedPings > 3 {
|
||||
if !remote.IsHealthy() {
|
||||
log.Printf("Removing host, unable to communicate with %s", host)
|
||||
p.RemoveHost(&remote)
|
||||
return
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user