test more
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 2m4s

This commit is contained in:
matst80
2024-11-12 08:04:06 +01:00
parent 652a09b620
commit de876ccbda

View File

@@ -74,8 +74,16 @@ func (p *SyncedPool) PongHandler(data []byte) (uint32, []byte, error) {
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
ids := make([]string, 0, len(p.local.grains))
for id := range p.local.grains {
ids = append(ids, id.String())
if p.local.grains[id] == nil {
continue
}
s := id.String()
if s == "" {
continue
}
ids = append(ids, s)
}
log.Printf("Returning %d cart ids\n", len(ids))
return CartIdsResponse, []byte(strings.Join(ids, ";")), nil
}
@@ -83,8 +91,10 @@ func (p *SyncedPool) NegotiateHandler(data []byte) (uint32, []byte, error) {
negotiationCount.Inc()
log.Printf("Handling negotiation\n")
for _, host := range p.ExcludeKnown(strings.Split(string(data), ";")) {
if !p.IsKnown(host) {
go p.AddRemote(host)
}
}
return RemoteNegotiateResponse, []byte("ok"), nil
}
@@ -118,7 +128,9 @@ func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (uint32, []byte, error
return AckChange, []byte("ok"), nil
}
}
return AckChange, []byte{}, fmt.Errorf("remote host not found")
go p.AddRemote(host)
return AckChange, []byte("ok"), nil
}
func NewSyncedPool(local *GrainLocalPool, hostname string, discovery Discovery) (*SyncedPool, error) {
@@ -264,6 +276,7 @@ func (g *RemoteHost) GetCartMappings() ([]CartId, error) {
return nil, err
}
if reply.StatusCode != 200 {
log.Printf("Remote returned error on get cart mappings: %s", string(reply.Data))
return nil, fmt.Errorf("remote returned error: %s", string(reply.Data))
}
parts := strings.Split(string(reply.Data), ";")