floodmeteo

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package floodmeteo is the library behind the floodmeteo command line: the HTTP client, request shaping, and the typed data models for the Open-Meteo Flood API (river discharge forecasts).

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load.

Index

Constants

View Source
const DefaultUserAgent = "floodmeteo/dev (+https://github.com/tamnd/floodmeteo-cli)"

DefaultUserAgent identifies the client to Open-Meteo.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// contains filtered or unexported fields
}

Client talks to the Open-Meteo Flood API over HTTPS.

func NewClient

func NewClient() *Client

NewClient returns a Client with DefaultConfig settings.

func NewClientFromConfig

func NewClientFromConfig(cfg Config) *Client

NewClientFromConfig builds a Client from the provided Config.

func (*Client) Forecast

func (c *Client) Forecast(ctx context.Context, lat, lon float64, days int) ([]*DailyDischarge, error)

Forecast fetches the daily river discharge forecast for the given coordinates and number of forecast days.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

type Config

type Config struct {
	BaseURL string
	Rate    time.Duration
	Retries int
	Timeout time.Duration
}

Config holds the tunable parameters for a Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the production config.

type DailyDischarge

type DailyDischarge struct {
	Time           string  `json:"time" kit:"id"`
	RiverDischarge float64 `json:"river_discharge"`
}

DailyDischarge is one day of river discharge forecast data.

type Domain

type Domain struct{}

Domain is the floodmeteo driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id). A lat,lon pair is classified as "latlon"; anything else as "query".

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL