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

internal/api/atomicasset.go: Pass context to atomicasset api.

This commit is contained in:
Henrik Hautakoski 2023-02-07 08:32:44 +01:00
parent 919599f86d
commit f0ab79ef06
No known key found for this signature in database
GPG key ID: 217490840C18A5D9
2 changed files with 8 additions and 9 deletions

View file

@ -11,7 +11,8 @@ import (
type AtomicAsset struct {
utils.Time
client atomicasset.Client
url string
block_time float64
}
@ -21,9 +22,7 @@ func AtomicAssetFactory(args ApiArguments) ApiInterface {
func NewAtomicAsset(url string, block_time float64) AtomicAsset {
return AtomicAsset{
client: atomicasset.Client{
URL: url,
},
url: url,
block_time: block_time,
}
}
@ -31,14 +30,15 @@ func NewAtomicAsset(url string, block_time float64) AtomicAsset {
func (e AtomicAsset) LogInfo() LogParams {
return LogParams{
"type", "atomicasset",
"url", e.client.URL,
"url", e.url,
"block_time", e.block_time,
}
}
func (e AtomicAsset) Call(ctx context.Context) (agentcheck.Response, string) {
// TODO: Pass context
h, err := e.client.GetHealth()
client := atomicasset.NewWithContext(e.url, ctx)
h, err := client.GetHealth()
if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Fail, "")
return resp, err.Error()

View file

@ -20,8 +20,7 @@ func TestAtomicAsset_Factory(t *testing.T) {
expected := NewAtomicAsset("https://atomic.example.com", 60)
assert.IsType(t, expected, api)
assert.Equal(t, expected.client.URL, api.(AtomicAsset).client.URL)
assert.Equal(t, expected.client.Host, api.(AtomicAsset).client.Host)
assert.Equal(t, expected.url, api.(AtomicAsset).url)
assert.Equal(t, expected.block_time, api.(AtomicAsset).block_time)
}