Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Support HAProxy's SPOP health check
Browse files Browse the repository at this point in the history
  • Loading branch information
mxey authored and mougams committed Nov 7, 2023
1 parent 1e923c1 commit 4470942
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ func (c *conn) handleHello(frame Frame) (Frame, map[string]bool, bool, error) {
return frame, nil, false, fmt.Errorf("hello: incompatible version %s, need %s", remoteSupportedVersions, version)
}

healthcheck, _ := data[helloKeyHealthcheck].(bool)

remoteCapabilitiesStr, ok := data[helloKeyCapabilities].(string)
if !ok {
return frame, nil, false, fmt.Errorf("hello: expected %s", helloKeyCapabilities)
}
remoteCapabilities := parseCapabilities(remoteCapabilitiesStr)
if !remoteCapabilities[capabilityPipelining] {
if !remoteCapabilities[capabilityPipelining] && !healthcheck {
// HAProxy never sends pipelining capability on healthcheck hellos
return frame, nil, false, fmt.Errorf("hello: expected pipelining capability")
}

c.engineID, _ = data[helloKeyEngineID].(string)
if len(c.engineID) == 0 {
if len(c.engineID) == 0 && !healthcheck {
// HAProxy never sends engine-id on healthcheck hellos
return frame, nil, false, fmt.Errorf("hello: engine-id not found")
}

Expand Down Expand Up @@ -106,8 +110,6 @@ func (c *conn) handleHello(frame Frame) (Frame, map[string]bool, bool, error) {

frame.data = frame.data[:off]

healthcheck, _ := data[helloKeyHealthcheck].(bool)

return frame, remoteCapabilities, healthcheck, nil
}

Expand Down

0 comments on commit 4470942

Please sign in to comment.