Documentation
¶
Overview ¶
Package neokit is the batteries-included layer: one constructor, then one method per feature — a.Database, a.Login, a.Backups, the notify senders. Calling a method is enabling the feature; each returns what it builds, so a missing dependency is a compile error, never a runtime lookup.
a, err := neokit.New(app.Options{Name: "myapp", Base: cfg.Base})
if err != nil { return err }
defer a.Close()
db, err := a.Database(cfg.DatabasePath, migrate)
gate := a.Login(fiberauth.Options{Sessions: store})
return a.Run()
Importing this package compiles every feature it fronts — SQLite, OIDC, the notify backends. A service that wants less imports app and the feature packages it actually uses; they compose identically, this is only the convenient spelling.
Index ¶
- type App
- func (a *App) Apprise(url string, o notify.Options) *notify.Apprise
- func (a *App) Backups(s backup.Snapshotter, o backup.Options) *backup.Service
- func (a *App) Database(path string, migrate func(*sql.DB) error) (*sql.DB, error)
- func (a *App) Login(o fiberauth.Options) *fiberauth.Gate
- func (a *App) Ntfy(topicURL, token string, o notify.Options) *notify.Ntfy
- func (a *App) Webhook(url, secret string, o notify.Options) *notify.Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
App is app.App plus one method per neokit feature. Everything the embedded app exports — HTTP, Shutdown, Run — is reachable unchanged.
func (*App) Backups ¶
Backups wires scheduled database backups and starts the daily schedule. See backup.New.
func (*App) Database ¶
Database opens the service's SQLite database and registers its teardown. See sqlitex.Open.
func (*App) Login ¶
Login builds the OIDC login gate, mounts its routes, and starts the expired-session sweep. See fiberauth.New.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package app is neokit's application builder: the boot sequence every service would otherwise retype, performed once in a documented order.
|
Package app is neokit's application builder: the boot sequence every service would otherwise retype, performed once in a documented order. |
|
Package backup turns a snapshot primitive into the two things an application needs: a fresh copy streamed on demand, and a dated copy written to disk on a schedule.
|
Package backup turns a snapshot primitive into the two things an application needs: a fresh copy streamed on demand, and a dated copy written to disk on a schedule. |
|
Package buildinfo reports the identity of the running binary: the version, commit and build date baked in at link time, plus the Go toolchain and target it was built for.
|
Package buildinfo reports the identity of the running binary: the version, commit and build date baked in at link time, plus the Go toolchain and target it was built for. |
|
Package cache provides a tiny in-memory TTL cache with per-key single-flight and stale-while-revalidate refreshes.
|
Package cache provides a tiny in-memory TTL cache with per-key single-flight and stale-while-revalidate refreshes. |
|
Package capset resolves optional capabilities out of a set of named components by type assertion, and memoises the answer.
|
Package capset resolves optional capabilities out of a set of named components by type assertion, and memoises the answer. |
|
Package clock supplies the two implementations of a Now() time.Time dependency: the real one, and a fake a test drives by hand.
|
Package clock supplies the two implementations of a Now() time.Time dependency: the real one, and a fake a test drives by hand. |
|
Package config holds the environment settings every service has, and the one call that parses them.
|
Package config holds the environment settings every service has, and the one call that parses them. |
|
Package disk reports free and total space on the filesystem holding a path.
|
Package disk reports free and total space on the filesystem holding a path. |
|
Package errs holds the error sentinels neokit's HTTP layer recognises without being told.
|
Package errs holds the error sentinels neokit's HTTP layer recognises without being told. |
|
examples
|
|
|
external-client
command
External-client calls a fixed upstream with a bounded timeout, idempotent retry policy, optional tracing, and structured errors.
|
External-client calls a fixed upstream with a bounded timeout, idempotent retry policy, optional tracing, and structured errors. |
|
minimal-api
command
Minimal-api is the smallest service built with app: configuration, standard middleware, structured errors, and graceful shutdown with one constructor.
|
Minimal-api is the smallest service built with app: configuration, standard middleware, structured errors, and graceful shutdown with one constructor. |
|
production-service
command
Production-service is the batteries-included layer: neokit.New, then one call per feature.
|
Production-service is the batteries-included layer: neokit.New, then one call per feature. |
|
Package fiberx holds cross-cutting Fiber v3 HTTP helpers: the error envelope, request binding/validation, metrics+logging middleware, rate limiting and optimistic-concurrency helpers.
|
Package fiberx holds cross-cutting Fiber v3 HTTP helpers: the error envelope, request binding/validation, metrics+logging middleware, rate limiting and optimistic-concurrency helpers. |
|
Package health answers the two questions an orchestrator asks, and keeps them apart.
|
Package health answers the two questions an orchestrator asks, and keeps them apart. |
|
Package httpc is the HTTP client core: a BaseClient for JSON APIs with built-in retries, bearer-token injection/refresh, and bounded reads; a Fault classification (see fault.go) that turns an error into "what should the caller do about it" instead of a status code to grep; and an SSRF-guarded transport (see ssrf.go) for fetching URLs a caller only partly controls.
|
Package httpc is the HTTP client core: a BaseClient for JSON APIs with built-in retries, bearer-token injection/refresh, and bounded reads; a Fault classification (see fault.go) that turns an error into "what should the caller do about it" instead of a status code to grep; and an SSRF-guarded transport (see ssrf.go) for fetching URLs a caller only partly controls. |
|
Package ids generates identifiers and secrets: UUIDGenerator for v4 UUIDs and CryptoTokenGenerator (see tokengen.go) for crypto-random tokens and passwords.
|
Package ids generates identifiers and secrets: UUIDGenerator for v4 UUIDs and CryptoTokenGenerator (see tokengen.go) for crypto-random tokens and passwords. |
|
Package jobs runs periodic background work correctly.
|
Package jobs runs periodic background work correctly. |
|
Package lifecycle owns process startup and shutdown: a context cancelled by the usual termination signals, and an ordered stack of teardown steps.
|
Package lifecycle owns process startup and shutdown: a context cancelled by the usual termination signals, and an ordered stack of teardown steps. |
|
Package logx holds the small slog helpers that make logs correlatable and consistent: a request-ID carried on the context, a handler decorator that stamps it onto every record, and a canonical error attribute.
|
Package logx holds the small slog helpers that make logs correlatable and consistent: a request-ID carried on the context, a handler decorator that stamps it onto every record, and a canonical error attribute. |
|
Package metrics wires the OpenTelemetry metrics pillar — the sibling of package tracing, and the third leg (with tracing plus the trace-correlated logs logx already emits) of a full traces + metrics + logs setup.
|
Package metrics wires the OpenTelemetry metrics pillar — the sibling of package tracing, and the third leg (with tracing plus the trace-correlated logs logx already emits) of a full traces + metrics + logs setup. |
|
Package netx holds small network helpers.
|
Package netx holds small network helpers. |
|
Package notify sends short operational notifications to the places a self-hosted deployment already has: a generic JSON webhook, an ntfy topic, or an Apprise API server.
|
Package notify sends short operational notifications to the places a self-hosted deployment already has: a generic JSON webhook, an ntfy topic, or an Apprise API server. |
|
Package oidcauth is a provider-agnostic OpenID Connect relying party: the half of a login that talks to an identity provider.
|
Package oidcauth is a provider-agnostic OpenID Connect relying party: the half of a login that talks to an identity provider. |
|
fiberauth
Package fiberauth is the browser-facing half of oidcauth: the Fiber v3 routes, cookies and middleware that turn a verified identity into a session and back again.
|
Package fiberauth is the browser-facing half of oidcauth: the Fiber v3 routes, cookies and middleware that turn a verified identity into a session and back again. |
|
Package pubsub is an in-process, topic-keyed fan-out for pushing events at connected clients — Server-Sent Events and WebSocket streams, where each browser subscribes to one topic (a user id, a job token, a room) and wants only that topic's events.
|
Package pubsub is an in-process, topic-keyed fan-out for pushing events at connected clients — Server-Sent Events and WebSocket streams, where each browser subscribes to one topic (a user id, a job token, a room) and wants only that topic's events. |
|
Package safe guards background work that runs outside a request's own recover middleware — schedulers, event hooks, detached goroutines — so a panic there is logged with a stack trace and contained, rather than crashing the whole process or silently ending that one goroutine forever.
|
Package safe guards background work that runs outside a request's own recover middleware — schedulers, event hooks, detached goroutines — so a panic there is logged with a stack trace and contained, rather than crashing the whole process or silently ending that one goroutine forever. |
|
Package session is the vocabulary for a signed-in browser, and one store that persists it.
|
Package session is the vocabulary for a signed-in browser, and one store that persists it. |
|
Package sqlitex provides SQLite operational helpers — a forward-only migration runner and a consistent snapshot — with no schema of its own.
|
Package sqlitex provides SQLite operational helpers — a forward-only migration runner and a consistent snapshot — with no schema of its own. |
|
Package tracing wires OpenTelemetry distributed tracing for the HTTP server.
|
Package tracing wires OpenTelemetry distributed tracing for the HTTP server. |
|
Package webpush holds the parts of Web Push (RFC 8030) that are pure key handling: generating a VAPID keypair (RFC 8292) and normalising the `sub` contact that rides in every VAPID JWT.
|
Package webpush holds the parts of Web Push (RFC 8030) that are pure key handling: generating a VAPID keypair (RFC 8292) and normalising the `sub` contact that rides in every VAPID JWT. |
|
delivery
Package delivery sends Web Push messages to the browsers subscribed to a topic, and prunes the ones that have gone away.
|
Package delivery sends Web Push messages to the browsers subscribed to a topic, and prunes the ones that have gone away. |