mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-03 11:53:43 +02:00
src/api/interface.go: remove Name() and define LogInfo() instead.
This commit is contained in:
parent
400ec204bc
commit
8e41cbfc5b
4 changed files with 19 additions and 8 deletions
|
|
@ -7,8 +7,8 @@ import (
|
||||||
|
|
||||||
type ApiInterface interface {
|
type ApiInterface interface {
|
||||||
|
|
||||||
// Name of the api
|
// Returns Logging information
|
||||||
Name() string
|
LogInfo() []interface{}
|
||||||
|
|
||||||
// Call api and validate it's status.
|
// Call api and validate it's status.
|
||||||
Call() (haproxy.HealthCheckStatus, string)
|
Call() (haproxy.HealthCheckStatus, string)
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,13 @@ func NewEosioV1(params eosapi.ReqParams, block_time float64) EosioV1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e EosioV1) Name() string {
|
func (e EosioV1) LogInfo() []interface{} {
|
||||||
return "v1"
|
return []interface{}{
|
||||||
|
"type", "eosio-v1",
|
||||||
|
"url", e.params.Url,
|
||||||
|
"host", e.params.Host,
|
||||||
|
"block_time", e.block_time,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e EosioV1) Call() (haproxy.HealthCheckStatus, string) {
|
func (e EosioV1) Call() (haproxy.HealthCheckStatus, string) {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,13 @@ func NewEosioV2(params eosapi.ReqParams, offset int64) EosioV2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e EosioV2) Name() string {
|
func (e EosioV2) LogInfo() []interface{} {
|
||||||
return "v2"
|
return []interface{}{
|
||||||
|
"type", "eosio-v2",
|
||||||
|
"url", e.params.Url,
|
||||||
|
"host", e.params.Host,
|
||||||
|
"offset", e.offset,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e EosioV2) Call() (haproxy.HealthCheckStatus, string) {
|
func (e EosioV2) Call() (haproxy.HealthCheckStatus, string) {
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,9 @@ func onTcpMessage(c *tcp_server.Client, args string) {
|
||||||
|
|
||||||
status, msg := healthCheckApi.Call()
|
status, msg := healthCheckApi.Call()
|
||||||
|
|
||||||
logger.Info("API Check", "type", healthCheckApi.Name(), "url", a.url,
|
logger.Info("API Check", append([]interface{}{
|
||||||
"block", a.block_time / 2, "status", status)
|
"status", status},
|
||||||
|
healthCheckApi.LogInfo()...)...)
|
||||||
|
|
||||||
if status != haproxy.HealthCheckUp && len(msg) > 0 {
|
if status != haproxy.HealthCheckUp && len(msg) > 0 {
|
||||||
logger.Warn("API Check Failed", "message", msg)
|
logger.Warn("API Check Failed", "message", msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue