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:
parent
919599f86d
commit
f0ab79ef06
2 changed files with 8 additions and 9 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue