1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +02:00

go: Update github.com/eosswedenorg-go/eosapi to v0.1.1

This commit is contained in:
Henrik Hautakoski 2022-10-12 12:25:42 +02:00
parent 8f81047e02
commit f5ff3480e0
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
4 changed files with 42 additions and 21 deletions

View file

@ -10,28 +10,30 @@ import (
type EosioV1 struct {
utils.Time
params eosapi.ReqParams
client eosapi.Client
block_time float64
}
func NewEosioV1(url string, host string, block_time float64) EosioV1 {
return EosioV1{
params: eosapi.ReqParams{
Url: url,
Host: host,
},
api := EosioV1{
client: *eosapi.New(url),
block_time: block_time,
}
api.client.Host = host
return api
}
func (e EosioV1) LogInfo() LogParams {
p := LogParams{
"type", "eosio-v1",
"url", e.params.Url,
"url", e.client.Url,
}
if len(e.params.Host) > 0 {
p.Add("host", e.params.Host)
if len(e.client.Host) > 0 {
p.Add("host", e.client.Host)
}
p.Add("block_time", e.block_time)
@ -41,7 +43,7 @@ func (e EosioV1) LogInfo() LogParams {
func (e EosioV1) Call() (agentcheck.Response, string) {
info, err := eosapi.GetInfo(e.params)
info, err := e.client.GetInfo()
if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
return resp, err.Error()

View file

@ -9,28 +9,30 @@ import (
)
type EosioV2 struct {
params eosapi.ReqParams
client eosapi.Client
offset int64
}
func NewEosioV2(url string, host string, offset int64) EosioV2 {
return EosioV2{
params: eosapi.ReqParams{
Url: url,
Host: host,
},
api := EosioV2{
client: *eosapi.New(url),
offset: offset,
}
api.client.Host = host
return api
}
func (e EosioV2) LogInfo() LogParams {
p := LogParams{
"type", "eosio-v2",
"url", e.params.Url,
"url", e.client.Url,
}
if len(e.params.Host) > 0 {
p.Add("host", e.params.Host)
if len(e.client.Host) > 0 {
p.Add("host", e.client.Host)
}
p.Add("offset", e.offset)
@ -40,7 +42,7 @@ func (e EosioV2) LogInfo() LogParams {
func (e EosioV2) Call() (agentcheck.Response, string) {
health, err := eosapi.GetHealth(e.params)
health, err := e.client.GetHealth()
if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
return resp, err.Error()