logging and client, context utils

This commit is contained in:
2024-11-16 14:02:46 -05:00
parent 46fa5ea6bf
commit 9af155dbde
15 changed files with 405 additions and 85 deletions

20
pkg/eia/eia_health.go Normal file
View File

@@ -0,0 +1,20 @@
package eia
import (
"context"
"fmt"
)
func (c *Client) Ping() error {
ctx, cncl := context.WithTimeout(c.ctx, c.healthCheckTimeout)
defer cncl()
resp, err := c.GetV2(ctx)
if err != nil {
return err
} else if resp.StatusCode != 200 {
return fmt.Errorf("non-200 response [%s] from eia api", resp.Status)
}
return nil
}