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:
parent
8f81047e02
commit
f5ff3480e0
4 changed files with 42 additions and 21 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue