test it
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m51s

This commit is contained in:
matst80
2024-11-10 20:30:12 +01:00
parent 8f0e062817
commit 113ecaccad
5 changed files with 42 additions and 40 deletions

View File

@@ -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) {