logging and client, context utils
This commit is contained in:
20
pkg/eia/eia_health.go
Normal file
20
pkg/eia/eia_health.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user