Documentation
¶
Overview ¶
Package handler exposes xpro-oss's HTTP surface: /healthz, /readyz, /process, /status.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers holds the dependencies every HTTP handler needs.
func New ¶
func New(base context.Context, opts Options, mapping []parser.Mapping, target process.Inserter, newSource SourceFactory) *Handlers
New constructs Handlers. base is the parent context of every run: cancel it on shutdown to interrupt an in-flight run (and use Wait to let it wind down). A nil base means context.Background().
func (*Handlers) RegisterRoutes ¶
func (h *Handlers) RegisterRoutes(mux *http.ServeMux, mws ...Middleware)
RegisterRoutes wires every endpoint onto mux. /healthz and /readyz are always unauthenticated (they're probes); mws wraps /process and /status, applied outermost-first — see Middleware. Called with no mws, xpro-oss's own endpoints are fully open, matching its "no auth baked into the generic core" scope; a closed-source layer built on xpro-oss supplies its own auth/audit/observability middleware here without forking this package.
type Middleware ¶
Middleware wraps an http.Handler to add cross-cutting behavior (auth, logging, metrics, tracing) without RegisterRoutes needing to know about it. This is the extension point a closed-source layer built on xpro-oss uses to add auth or observability on top — decorate, don't fork.
func Chain ¶
func Chain(mws ...Middleware) Middleware
Chain composes middleware in the order given: Chain(a, b, c)(h) runs as a(b(c(h))) — a is outermost, so a request hits a first. Chain() with no arguments is the identity: it returns h unchanged.
type Options ¶
type Options struct {
BatchSize int // 0 = the target's default
Workers int // 0 = pipeline default
RunTimeout time.Duration // 0 = 30 minutes
}
Options tunes how /process runs the pipeline. The zero value is usable.
type SourceFactory ¶
SourceFactory opens a fresh source for one /process run. closeFn, if non-nil, is called when the run ends (an SFTP source connects a new session per run; os.DirFS needs neither connecting nor closing). The factory — not the pipeline — owns the source's lifecycle.