Documentation
¶
Overview ¶
Package carb is the library behind the carb command line: the HTTP client, request shaping, and the typed data models for the UK Carbon Intensity API (api.carbonintensity.org.uk). No API key required.
Package carb exposes the UK Carbon Intensity API as a kit Domain driver.
A multi-domain host (ant) enables it with a single blank import:
import _ "github.com/tamnd/carb-cli/carb"
The same Domain also builds the standalone carb binary (see cli.NewApp).
Index ¶
Constants ¶
const Host = "api.carbonintensity.org.uk"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Carbon Intensity API over HTTP.
func (*Client) Generation ¶
func (c *Client) Generation(ctx context.Context) (*Generation, error)
Generation fetches the current generation mix.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the carb driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Generation ¶
type Generation struct {
From string `json:"from"`
To string `json:"to"`
Mix []GenFuel `json:"mix"`
}
Generation is the current generation mix.