Documentation
¶
Overview ¶
Package sheetsdb provides generic Google Sheets fetchers backed by a config-indexed workbook pattern. It does not provide an Updater: Sheets are read-only sources.
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
const MaxSourceBytes = 16 << 20
Variables ¶
var ErrSourceNotConfigured = errors.New("source not configured")
var ErrSourceNotFound = errors.New("source not found")
Functions ¶
func NormalizeConfigKey ¶
NormalizeConfigKey lowercases, trims, and applies collection aliases.
func NormalizeEnvironmentKey ¶
NormalizeEnvironmentKey normalizes an environment key by lowercasing, trimming, and stripping an optional env: prefix.
Types ¶
type Config ¶
type Config struct {
Rows []ConfigRow
}
Config is the typed config-tab result. Rows stay ordered so duplicate keys can be detected instead of silently resolved by map iteration.
func LoadConfig ¶
LoadConfig fetches and caches the workbook config tab using a process-wide cache.
func (Config) Environment ¶
Environment returns a normalized environment value. Both NAME and env:NAME forms are accepted.
func (Config) EnvironmentValues ¶
EnvironmentValues returns ALL_CAPS and env:-prefixed config values.
type ConfigCache ¶
type ConfigCache struct {
// contains filtered or unexported fields
}
ConfigCache provides thread-safe, once-only loading of a workbook's config tab.
type ConfigRow ¶
type ConfigRow struct {
Description string `json:"description"`
Key string `json:"key"`
Value string `json:"value"`
}
ConfigRow is the required shape of the workbook's index tab.
type IndexedFetcher ¶
type IndexedFetcher[T any] struct { IndexURL string Key string Client *http.Client Config *ConfigCache }
IndexedFetcher resolves a source tab URL from the workbook's config tab, then fetches and decodes that tab into T.
type OptionalIndexedFetcher ¶
type OptionalIndexedFetcher[T any] struct{ Indexed IndexedFetcher[T] }
OptionalIndexedFetcher treats a missing config source as an empty source.
type WebFetcher ¶
WebFetcher fetches one Google Sheets tab (or local CSV/TSV file) and decodes it into T. T should use json tags, and nullable source cells should use csvx fields.