mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-03 11:53:43 +02:00
internal/api/atomicasset.go: Pass context to atomicasset api.
This commit is contained in:
parent
919599f86d
commit
f0ab79ef06
2 changed files with 8 additions and 9 deletions
|
|
@ -11,7 +11,8 @@ import (
|
||||||
|
|
||||||
type AtomicAsset struct {
|
type AtomicAsset struct {
|
||||||
utils.Time
|
utils.Time
|
||||||
client atomicasset.Client
|
|
||||||
|
url string
|
||||||
block_time float64
|
block_time float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,9 +22,7 @@ func AtomicAssetFactory(args ApiArguments) ApiInterface {
|
||||||
|
|
||||||
func NewAtomicAsset(url string, block_time float64) AtomicAsset {
|
func NewAtomicAsset(url string, block_time float64) AtomicAsset {
|
||||||
return AtomicAsset{
|
return AtomicAsset{
|
||||||
client: atomicasset.Client{
|
url: url,
|
||||||
URL: url,
|
|
||||||
},
|
|
||||||
block_time: block_time,
|
block_time: block_time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,14 +30,15 @@ func NewAtomicAsset(url string, block_time float64) AtomicAsset {
|
||||||
func (e AtomicAsset) LogInfo() LogParams {
|
func (e AtomicAsset) LogInfo() LogParams {
|
||||||
return LogParams{
|
return LogParams{
|
||||||
"type", "atomicasset",
|
"type", "atomicasset",
|
||||||
"url", e.client.URL,
|
"url", e.url,
|
||||||
"block_time", e.block_time,
|
"block_time", e.block_time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e AtomicAsset) Call(ctx context.Context) (agentcheck.Response, string) {
|
func (e AtomicAsset) Call(ctx context.Context) (agentcheck.Response, string) {
|
||||||
// TODO: Pass context
|
client := atomicasset.NewWithContext(e.url, ctx)
|
||||||
h, err := e.client.GetHealth()
|
|
||||||
|
h, err := client.GetHealth()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp := agentcheck.NewStatusMessageResponse(agentcheck.Fail, "")
|
resp := agentcheck.NewStatusMessageResponse(agentcheck.Fail, "")
|
||||||
return resp, err.Error()
|
return resp, err.Error()
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@ func TestAtomicAsset_Factory(t *testing.T) {
|
||||||
expected := NewAtomicAsset("https://atomic.example.com", 60)
|
expected := NewAtomicAsset("https://atomic.example.com", 60)
|
||||||
|
|
||||||
assert.IsType(t, expected, api)
|
assert.IsType(t, expected, api)
|
||||||
assert.Equal(t, expected.client.URL, api.(AtomicAsset).client.URL)
|
assert.Equal(t, expected.url, api.(AtomicAsset).url)
|
||||||
assert.Equal(t, expected.client.Host, api.(AtomicAsset).client.Host)
|
|
||||||
assert.Equal(t, expected.block_time, api.(AtomicAsset).block_time)
|
assert.Equal(t, expected.block_time, api.(AtomicAsset).block_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue