Documentation
¶
Overview ¶
Package api is the HTTP layer: chi router, request/response glue, and middleware. It depends only on the model interfaces and a few injected http.Handlers/middlewares, so the subsystem implementations can be developed independently and wired in at startup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DocsHandler ¶
DocsHandler serves the embedded API docs page as text/html. It is a plain http.Handler so the orchestrator can mount it at /tr/v1/docs and gate it behind a config flag (off by default per ADR 0017); this handler reads no config of its own. The page renders the runtime spec at /v0/openapi.json entirely client-side, so nothing here needs the pipe registry.
Types ¶
type Deps ¶
type Deps struct {
Ingester model.Ingester // POST /v0/events
Pipes model.PipeRunner // GET /v0/pipes/{name}.{json,csv,ndjson,parquet}
CopyRunner model.CopyRunner // POST /v0/pipes/{name}/copy (optional; needs PipeReg)
PipeReg model.PipeRegistry // GET /v0/pipes, /v0/pipes/{name} (optional)
Datasources model.DatasourceRegistry // GET /v0/datasources[/{name}] (optional)
Tokens model.TokenStore // auth middleware
RedisPing model.Pinger // readiness
CHPing model.Pinger // readiness
// Phase 2 add-ons (optional).
SQLProxy http.Handler // GET/POST /v0/sql (ADR 0011)
MetricsHandler http.Handler // GET /v0/metrics (Prometheus)
MetricsMiddleware func(http.Handler) http.Handler // per-request metrics
RateLimit func(http.Handler) http.Handler // per-token limiter on pipes (ADR 0015)
OpenAPI func() []byte // GET /v0/openapi.json (ADR 0017)
IngestObserver func(successful, quarantined int) // events -> metrics hook
DocsUI http.Handler // /tr/v1/docs page (ADR 0017)
DocsEnabled bool // serve the docs UI (off by default)
// MaxCompressedBytes caps the on-the-wire request body (ADR 0023). 0 -> 10MB.
MaxCompressedBytes int64
}
Deps are the concrete subsystem implementations the HTTP layer drives. The http.Handler / middleware / func fields are optional (nil-checked) so the server degrades gracefully if a piece isn't wired.