mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-18 05:00:03 +02:00
Change order of request parameters: api field moved from position 3 to 1 and are now required.
This commit is contained in:
parent
014027006f
commit
f6aabb7ed8
2 changed files with 21 additions and 12 deletions
|
|
@ -41,9 +41,9 @@ first to last below:
|
|||
|
||||
| # | Name | Required | Description |
|
||||
| - | ---------- | ----------------------- | -------------------------------------------------------------- |
|
||||
| 1 | url | Yes (port default `80`) | http url to the api. `http(s)://<ip-or-domain>(:<port>)` |
|
||||
| 2 | num_blocks | No (default `10`) | Number of blocks the api can drift before reported `down` |
|
||||
| 3 | api | No (default `v1`) | Type of API to check against, `v1` = standard, `v2` = Hyperion |
|
||||
| 1 | api | Yes | Type of API to check against, `v1` = standard, `v2` = Hyperion |
|
||||
| 2 | url | Yes (port default `80`) | http url to the api. `http(s)://<ip-or-domain>(:<port>)` |
|
||||
| 3 | num_blocks | No (default `10`) | Number of blocks the api can drift before reported `down` |
|
||||
| 4 | host | No (default from `url`) | Value to send in the `HTTP Host Header` to the API |
|
||||
|
||||
### Response
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ type arguments struct {
|
|||
func createApi(a *arguments) api.ApiInterface {
|
||||
|
||||
switch a.api {
|
||||
case "contract":
|
||||
return api.NewEosioContract(a.url, float64(a.block_time))
|
||||
case "v2":
|
||||
return api.NewEosioV2(eosapi.ReqParams{Url: a.url, Host: a.host}, int64(a.block_time / 2))
|
||||
}
|
||||
|
|
@ -45,22 +47,29 @@ func onTcpMessage(c *tcp_server.Client, args string) {
|
|||
// -------------------
|
||||
split := strings.Split(strings.TrimSpace(args), "|")
|
||||
|
||||
// 1. url (scheme + ip/domain + port)
|
||||
a.url = split[0]
|
||||
if len(split) < 2 {
|
||||
msg := "Invalid number of parameters in agent request"
|
||||
|
||||
// 2. Block time.
|
||||
logger.Warn("Agent request error", "message", msg, "args", split)
|
||||
c.WriteString(fmt.Sprintf("%s#%s\n", haproxy.HealthCheckFailed, msg))
|
||||
c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// 1. Api
|
||||
a.api = split[0]
|
||||
|
||||
// 2. url (scheme + ip/domain + port)
|
||||
a.url = split[1]
|
||||
|
||||
// 3. Block time.
|
||||
if len(split) > 1 {
|
||||
num, err := strconv.ParseInt(split[1], 10, 32)
|
||||
num, err := strconv.ParseInt(split[2], 10, 32)
|
||||
if err == nil {
|
||||
a.block_time = int(num)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Api
|
||||
if len(split) > 2 {
|
||||
a.api = split[2]
|
||||
}
|
||||
|
||||
// 4. Host
|
||||
if len(split) > 3 {
|
||||
a.host = split[3]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue