1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-07-04 12:03:43 +02:00

server.go: rename "v2" parameter to "version" and make it a string.

This commit is contained in:
Henrik Hautakoski 2020-02-07 07:14:23 +01:00
parent c061878b42
commit 4a73480603
2 changed files with 9 additions and 12 deletions

View file

@ -17,12 +17,12 @@ The protocol is simple and has 4 rules.
The following parameters are supported in a request and are ordered from The following parameters are supported in a request and are ordered from
first to last below: first to last below:
| # | Name | Required | Description | | # | Name | Required | Description |
| - | ---------- | -------- | ---------------------------------------------------------------------- | | - | ---------- | -------- | ----------------------------------------------------------------------------- |
| 1 | Host | Yes | IP/Hostname to the api. | | 1 | Host | Yes | IP/Hostname to the api. |
| 2 | Port | No | Port number to the api (default `80`) | | 2 | Port | No | Port number to the api (default `80`) |
| 3 | num_blocks | No | Number of blocks the api can drift before reported `down` (default 10) | | 3 | num_blocks | No | Number of blocks the api can drift before reported `down` (default 10) |
| 4 | hyperion | No | `1` if hyperion healthcheck should be used (default `0`) | | 4 | version | No | API Version to check against, `v1` = standard, `v2` = Hyperion (default `v1`) |
### Response ### Response

View file

@ -118,7 +118,7 @@ func main() {
var host string var host string
var port int = 80 var port int = 80
var block_time int = 10 var block_time int = 10
var v2 bool = false; var version string = "v1"
// Parse host + port. // Parse host + port.
split := strings.Split(strings.TrimSpace(message), ":") split := strings.Split(strings.TrimSpace(message), ":")
@ -137,17 +137,14 @@ func main() {
} }
} }
if len(split) > 3 { if len(split) > 3 {
p, err := strconv.ParseInt(split[3], 10, 32) version = split[3]
if err == nil {
v2 = p != 0;
}
} }
// Check api. // Check api.
var status haproxy.HealthCheckStatus var status haproxy.HealthCheckStatus
var msg string var msg string
if v2 { if version == "v2" {
status, msg = check_api_v2(host, port, int64(block_time / 2)) status, msg = check_api_v2(host, port, int64(block_time / 2))
} else { } else {
status, msg = check_api(host, port, float64(block_time)) status, msg = check_api(host, port, float64(block_time))