This commit is contained in:
@@ -21,7 +21,7 @@ type RemoteHost struct {
|
||||
*Client
|
||||
Host string
|
||||
MissedPings int
|
||||
Pool *RemoteGrainPool
|
||||
//Pool *RemoteGrainPool
|
||||
}
|
||||
|
||||
type SyncedPool struct {
|
||||
@@ -358,33 +358,38 @@ func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) AddRemote(address string) error {
|
||||
if address == "" || p.IsKnown(address) {
|
||||
func (p *SyncedPool) AddRemote(host string) error {
|
||||
if host == "" || p.IsKnown(host) {
|
||||
return nil
|
||||
}
|
||||
client, err := Dial(fmt.Sprintf("%s:1338", address))
|
||||
client, err := Dial(fmt.Sprintf("%s:1338", host))
|
||||
if err != nil {
|
||||
log.Printf("Error connecting to remote %s: %v\n", host, err)
|
||||
}
|
||||
_, err = client.Call(Ping, Pong, nil)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error connecting to remote %s: %v\n", address, err)
|
||||
log.Printf("Error pinging remote %s: %v\n", host, err)
|
||||
return err
|
||||
}
|
||||
|
||||
pool := NewRemoteGrainPool(address)
|
||||
//pool := NewRemoteGrainPool(host)
|
||||
remote := RemoteHost{
|
||||
Client: client,
|
||||
Pool: pool,
|
||||
Host: address,
|
||||
// Pool: pool,
|
||||
Host: host,
|
||||
}
|
||||
|
||||
go func() {
|
||||
for range client.Errors {
|
||||
if client.ErrorCount > 3 {
|
||||
log.Printf("Error count exceeded, removing remote %s\n", host)
|
||||
p.RemoveHost(&remote)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return p.addRemoteHost(address, &remote)
|
||||
return p.addRemoteHost(host, &remote)
|
||||
}
|
||||
|
||||
func (p *SyncedPool) getGrain(id CartId) (Grain, error) {
|
||||
|
||||
Reference in New Issue
Block a user