handler

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (*Handlers) Wait

func (h *Handlers) Wait(ctx context.Context) error

Wait blocks until any in-flight run has finished or ctx is done.

type Middleware

type Middleware func(http.Handler) http.Handler

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

type SourceFactory func(ctx context.Context) (fsys fs.FS, closeFn func() error, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL