diff options
| author | bndw <ben@bdw.to> | 2026-02-14 12:14:19 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 12:14:19 -0800 |
| commit | ea4f508f5ee91b370c6912cde26b1a432380d037 (patch) | |
| tree | 79081398bc0da1db76c28de6de04ed88a5e53bc3 /internal/metrics | |
| parent | 4fc493e6d8cc20137f920f8647e39fc5051bb245 (diff) | |
feat: integrate config system into relay main.go
Add support for loading configuration from YAML file via -config flag.
Wire up auth, rate limiting, and metrics interceptors based on config.
Changes:
- Add -config flag to relay command
- Use config types directly in auth package (AuthOperationConfig)
- Add conversion methods: RateLimitConfig.ToRateLimiter(), MetricsConfig.ToMetrics()
- Add Metrics.Serve() method for prometheus HTTP endpoint
- Update main.go to initialize interceptors from config
- Fix type naming: OperationAuthConfig -> AuthOperationConfig for consistency
Config now supports complete relay setup including auth read/write
allowlists, rate limiting, and prometheus metrics.
Diffstat (limited to 'internal/metrics')
| -rw-r--r-- | internal/metrics/metrics.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 3cb675f..9030d67 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | package metrics | 1 | package metrics |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "net/http" | ||
| 5 | |||
| 4 | "github.com/prometheus/client_golang/prometheus" | 6 | "github.com/prometheus/client_golang/prometheus" |
| 5 | "github.com/prometheus/client_golang/prometheus/promauto" | 7 | "github.com/prometheus/client_golang/prometheus/promauto" |
| 8 | "github.com/prometheus/client_golang/prometheus/promhttp" | ||
| 6 | ) | 9 | ) |
| 7 | 10 | ||
| 8 | // Metrics holds all Prometheus metrics for the relay. | 11 | // Metrics holds all Prometheus metrics for the relay. |
| @@ -280,3 +283,9 @@ const ( | |||
| 280 | StatusRateLimited RequestStatus = "rate_limited" | 283 | StatusRateLimited RequestStatus = "rate_limited" |
| 281 | StatusInvalidRequest RequestStatus = "invalid_request" | 284 | StatusInvalidRequest RequestStatus = "invalid_request" |
| 282 | ) | 285 | ) |
| 286 | |||
| 287 | func (m *Metrics) Serve(addr, path string) error { | ||
| 288 | mux := http.NewServeMux() | ||
| 289 | mux.Handle(path, promhttp.Handler()) | ||
| 290 | return http.ListenAndServe(addr, mux) | ||
| 291 | } | ||
