Add maintained configuration examples

This commit is contained in:
2026-06-10 20:17:40 +00:00
parent f0605781a2
commit 9e27a431a1
9 changed files with 129 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ current working directory.
- [Configuration reference](docs/config.md) - [Configuration reference](docs/config.md)
- [Operations guide](docs/operations.md) - [Operations guide](docs/operations.md)
- [Troubleshooting guide](docs/troubleshooting.md) - [Troubleshooting guide](docs/troubleshooting.md)
- [Example configs](examples/)
- [Event wire contract](docs/integrations/events.md) - [Event wire contract](docs/integrations/events.md)
- [Postgres table contract](docs/integrations/postgres.md) - [Postgres table contract](docs/integrations/postgres.md)
- [Architecture policy](docs/policy/architecture.md) - [Architecture policy](docs/policy/architecture.md)

View File

@@ -24,7 +24,7 @@ sources:
# driver: openweather_observation # driver: openweather_observation
# every: 10m # every: 10m
# params: # params:
# url: "https://api.openweathermap.org/data/2.5/weather?lat=38.6239&lon=-90.3571&appid=c954f2566cb7ccb56b43737b52e88fc6&units=metric" # url: "https://api.openweathermap.org/data/2.5/weather?lat=38.6239&lon=-90.3571&units=metric"
# user_agent: "HomeOps (eric@maximumdirect.net)" # user_agent: "HomeOps (eric@maximumdirect.net)"
# - name: NWSObservationKSUS # - name: NWSObservationKSUS
@@ -115,7 +115,7 @@ sinks:
# params: # params:
# uri: postgres://weatherdb:5432/weatherdb?sslmode=disable # uri: postgres://weatherdb:5432/weatherdb?sslmode=disable
# username: weatherdb # username: weatherdb
# password: weatherdb # password: <database_password>
# prune: 3d # prune: 3d
# # Prunes rows older than now-3d on each write transaction. # # Prunes rows older than now-3d on each write transaction.

View File

@@ -2,7 +2,9 @@ package main
import ( import (
"context" "context"
"path/filepath"
"reflect" "reflect"
"sort"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -82,6 +84,33 @@ func TestExampleConfigSourcesBuildSchedulerJobs(t *testing.T) {
t.Fatalf("config.Load(config.yml) unexpected error: %v", err) t.Fatalf("config.Load(config.yml) unexpected error: %v", err)
} }
assertConfigSourcesBuildSchedulerJobs(t, cfg)
}
func TestMaintainedConfigExamplesLoad(t *testing.T) {
paths, err := filepath.Glob("../../examples/*.yml")
if err != nil {
t.Fatalf("filepath.Glob examples: %v", err)
}
sort.Strings(paths)
if len(paths) == 0 {
t.Fatalf("expected maintained config examples")
}
for _, path := range paths {
t.Run(filepath.Base(path), func(t *testing.T) {
cfg, err := config.Load(path)
if err != nil {
t.Fatalf("config.Load(%s) unexpected error: %v", path, err)
}
assertConfigSourcesBuildSchedulerJobs(t, cfg)
})
}
}
func assertConfigSourcesBuildSchedulerJobs(t *testing.T, cfg *config.Config) {
t.Helper()
reg := fksources.NewRegistry() reg := fksources.NewRegistry()
wfsources.RegisterBuiltins(reg) wfsources.RegisterBuiltins(reg)
@@ -91,6 +120,10 @@ func TestExampleConfigSourcesBuildSchedulerJobs(t *testing.T) {
t.Fatalf("BuildInput(sources[%d]) error = %v", i, err) t.Fatalf("BuildInput(sources[%d]) error = %v", i, err)
} }
if err := fksources.ValidateExpectedKinds(sc, in); err != nil {
t.Fatalf("ValidateExpectedKinds(sources[%d]) error = %v", i, err)
}
job, err := fkscheduler.JobFromSourceConfig(in, sc) job, err := fkscheduler.JobFromSourceConfig(in, sc)
if err != nil { if err != nil {
t.Fatalf("JobFromSourceConfig(sources[%d]) error = %v", i, err) t.Fatalf("JobFromSourceConfig(sources[%d]) error = %v", i, err)

View File

@@ -46,6 +46,8 @@ cd cmd/weatherfeeder
go run . go run .
``` ```
Maintained copyable configs are available under [`examples/`](../examples/).
Build and run a local binary: Build and run a local binary:
```sh ```sh

View File

@@ -34,6 +34,7 @@ routes:
`sources` and `sinks` must each contain at least one entry. `routes` is optional. `sources` and `sinks` must each contain at least one entry. `routes` is optional.
When `routes` is omitted, every configured sink receives every event kind. When `routes` is omitted, every configured sink receives every event kind.
Maintained copyable configs are available under [`examples/`](../examples/).
## Production-Oriented Shape ## Production-Oriented Shape
@@ -63,7 +64,7 @@ sinks:
params: params:
uri: postgres://weatherdb:5432/weatherdb?sslmode=disable uri: postgres://weatherdb:5432/weatherdb?sslmode=disable
username: weatherdb username: weatherdb
password: "<set outside source control>" password: <database_password>
prune: 3d prune: 3d
routes: routes:
@@ -213,3 +214,9 @@ Postgres `prune` must be a string duration.
The config file is read directly from disk and has no built-in secret expansion. The config file is read directly from disk and has no built-in secret expansion.
Keep real credentials out of repository-tracked configs. Use deployment tooling Keep real credentials out of repository-tracked configs. Use deployment tooling
to render `config.yml` with the needed secret values before starting the daemon. to render `config.yml` with the needed secret values before starting the daemon.
## Maintained Examples
- [Minimal stdout config](../examples/config.minimal.yml)
- [NATS publishing config](../examples/config.nats.yml)
- [Postgres persistence config](../examples/config.postgres.yml)

View File

@@ -16,6 +16,8 @@ CLI surface, see [CLI reference](cli.md).
The daemon has no admin subcommands and no runtime reload command. Change the The daemon has no admin subcommands and no runtime reload command. Change the
config file and restart the process to apply configuration changes. config file and restart the process to apply configuration changes.
Maintained copyable configs are available under [`examples/`](../examples/).
## Runtime Lifecycle ## Runtime Lifecycle
On startup, `weatherfeeder`: On startup, `weatherfeeder`:

View File

@@ -0,0 +1,19 @@
---
sources:
- name: NWSObservationKSTL
mode: poll
kinds: ["observation"]
driver: nws_observation
every: 10m
params:
url: "https://api.weather.gov/stations/KSTL/observations/latest"
user_agent: "weatherfeeder example (operator@example.com)"
sinks:
- name: stdout
driver: stdout
params: {}
routes:
- sink: stdout
kinds: ["observation"]

30
examples/config.nats.yml Normal file
View File

@@ -0,0 +1,30 @@
---
sources:
- name: NWSObservationKSTL
mode: poll
kinds: ["observation"]
driver: nws_observation
every: 10m
params:
url: "https://api.weather.gov/stations/KSTL/observations/latest"
user_agent: "weatherfeeder example (operator@example.com)"
- name: NWSAlertsSTL
mode: poll
kinds: ["alert"]
driver: nws_alerts
every: 1m
params:
url: "https://api.weather.gov/alerts?point=38.6239,-90.3571&limit=20"
user_agent: "weatherfeeder example (operator@example.com)"
sinks:
- name: nats_weather
driver: nats
params:
url: nats://localhost:4222
subject: weatherfeeder.events
routes:
- sink: nats_weather
kinds: ["observation", "alert"]

View File

@@ -0,0 +1,32 @@
---
sources:
- name: NWSObservationKSTL
mode: poll
kinds: ["observation"]
driver: nws_observation
every: 10m
params:
url: "https://api.weather.gov/stations/KSTL/observations/latest"
user_agent: "weatherfeeder example (operator@example.com)"
- name: OpenMeteoHourlyForecastSTL
mode: poll
kinds: ["forecast"]
driver: openmeteo_forecast
every: 1h
params:
url: "https://api.open-meteo.com/v1/forecast?latitude=38.6239&longitude=-90.3571&hourly=temperature_2m,relative_humidity_2m,dew_point_2m,apparent_temperature,precipitation_probability,precipitation,snowfall,weather_code,surface_pressure,wind_speed_10m,wind_direction_10m&forecast_days=3"
user_agent: "weatherfeeder example (operator@example.com)"
sinks:
- name: pg_weather
driver: postgres
params:
uri: "postgres://postgres.example.invalid:5432/weatherfeeder?sslmode=disable"
username: <database_username>
password: <database_password>
prune: 3d
routes:
- sink: pg_weather
kinds: ["observation", "forecast"]