mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-19 05:10:02 +02:00
server.go: rename "v2" parameter to "version" and make it a string.
This commit is contained in:
parent
c061878b42
commit
4a73480603
2 changed files with 9 additions and 12 deletions
12
README.md
12
README.md
|
|
@ -17,12 +17,12 @@ The protocol is simple and has 4 rules.
|
|||
The following parameters are supported in a request and are ordered from
|
||||
first to last below:
|
||||
|
||||
| # | Name | Required | Description |
|
||||
| - | ---------- | -------- | ---------------------------------------------------------------------- |
|
||||
| 1 | Host | Yes | IP/Hostname to the api. |
|
||||
| 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) |
|
||||
| 4 | hyperion | No | `1` if hyperion healthcheck should be used (default `0`) |
|
||||
| # | Name | Required | Description |
|
||||
| - | ---------- | -------- | ----------------------------------------------------------------------------- |
|
||||
| 1 | Host | Yes | IP/Hostname to the api. |
|
||||
| 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) |
|
||||
| 4 | version | No | API Version to check against, `v1` = standard, `v2` = Hyperion (default `v1`) |
|
||||
|
||||
### Response
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func main() {
|
|||
var host string
|
||||
var port int = 80
|
||||
var block_time int = 10
|
||||
var v2 bool = false;
|
||||
var version string = "v1"
|
||||
|
||||
// Parse host + port.
|
||||
split := strings.Split(strings.TrimSpace(message), ":")
|
||||
|
|
@ -137,17 +137,14 @@ func main() {
|
|||
}
|
||||
}
|
||||
if len(split) > 3 {
|
||||
p, err := strconv.ParseInt(split[3], 10, 32)
|
||||
if err == nil {
|
||||
v2 = p != 0;
|
||||
}
|
||||
version = split[3]
|
||||
}
|
||||
|
||||
// Check api.
|
||||
var status haproxy.HealthCheckStatus
|
||||
var msg string
|
||||
|
||||
if v2 {
|
||||
if version == "v2" {
|
||||
status, msg = check_api_v2(host, port, int64(block_time / 2))
|
||||
} else {
|
||||
status, msg = check_api(host, port, float64(block_time))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue