Documentation
¶
Index ¶
- func Run(opts Options) error
- func WaitForShutdown() <-chan os.Signal
- type Builder
- func (b *Builder) FullBuild(ctx context.Context) error
- func (b *Builder) HandleContentChanged(ctx context.Context, event eventbus.Event) error
- func (b *Builder) IncrementalBuild(ctx context.Context, changedFiles []string) error
- func (b *Builder) QueueBuild(ctx context.Context, buildFn func() error) error
- func (b *Builder) RenderPageJIT(ctx context.Context, pageURL string) (string, error)
- func (b *Builder) TriggerRebuild()
- type BuilderOptions
- type Daemon
- type HealthChecker
- type MetricsCollector
- func (m *MetricsCollector) Handler() http.Handler
- func (m *MetricsCollector) RecordBuild(duration time.Duration)
- func (m *MetricsCollector) RecordBuildFailure()
- func (m *MetricsCollector) RecordCacheHit()
- func (m *MetricsCollector) RecordCacheMiss()
- func (m *MetricsCollector) RecordRequest(method, path string, duration time.Duration)
- type Options
- type Serving
- type ServingOptions
- type SystemdNotifier
- type Watcher
- type WatcherOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForShutdown ¶
WaitForShutdown returns a channel that fires on SIGINT/SIGTERM.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder manages the full build and incremental update pipeline.
func (*Builder) FullBuild ¶
FullBuild runs the complete 8-stage build pipeline. Uses the serialized build queue to prevent concurrent builds.
func (*Builder) HandleContentChanged ¶
HandleContentChanged is called when content changes are detected.
func (*Builder) IncrementalBuild ¶
IncrementalBuild rebuilds only the pages affected by the given file changes. It uses the DAG to determine affected pages and build.IncrementalRender to re-render only those pages, reusing the cached pipeline state.
Falls back to a full build when:
- a template/i18n/config/theme file changed (cache invalid)
- no PipelineCache is available
- the DAG is empty (no prior full build)
func (*Builder) QueueBuild ¶
QueueBuild ensures only one build runs at a time. If a build is in progress, it marks pending and returns (the running build will trigger a trailing rebuild). This coalesces multiple concurrent change events into a single rebuild.
func (*Builder) RenderPageJIT ¶
RenderPageJIT renders a single page on demand for JIT fallback. Reuses the cached pipeline state for speed. Returns the HTML (not written to disk); the caller (serving.jitFallback) caches it in JITCache.
Tries the fast path (JITRenderFast) first for regular pages: loads only the target page, renders only its markdown, and builds only its context. Falls back to the full RenderPageWithCache for list pages or when the cache is not yet populated.
Returns an error (→ 404 in serving layer) when the source file cannot be resolved or does not exist on disk.
func (*Builder) TriggerRebuild ¶
func (b *Builder) TriggerRebuild()
TriggerRebuild is an external trigger (from Admin API) to rebuild.
type BuilderOptions ¶
type BuilderOptions struct {
SourceDir string
OutputDir string
Bus eventbus.EventBus
DAG *dag.DependencyGraph
JITCache *cache.JITCache
Metrics *MetricsCollector
BuildDrafts bool
Logf func(format string, args ...any)
// OnAfterBuild is called after a successful full build completes.
// This is separate from the build's AfterBuild which captures the RenderPageFunc.
OnAfterBuild func(*build.Result) error
// PipelineCache holds reusable build state for incremental builds.
// Populated after the first full build (via build.Options.PipelineCache).
// When nil, IncrementalBuild falls back to a full build.
PipelineCache *build.PipelineCache
// ContentIndex is reloaded from <OutputDir>/api/*.json after each build
// so the /api/v1/* query API serves fresh data. Optional: when nil, the
// reload hook is skipped.
ContentIndex *contentindex.ContentIndex
// ThemeManager, if non-nil, is passed to build.Options.ThemeManager
// for full builds, incremental builds, and JIT rendering.
ThemeManager *theme.Manager
}
BuilderOptions configures the Builder.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon holds the long-running server state.
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker provides health check endpoint.
func NewHealthChecker ¶
func NewHealthChecker() *HealthChecker
NewHealthChecker creates a HealthChecker.
func (*HealthChecker) Handler ¶
func (h *HealthChecker) Handler() http.HandlerFunc
Handler returns the HTTP handler for health checks.
func (*HealthChecker) SetReady ¶
func (h *HealthChecker) SetReady(ready bool)
SetReady marks the daemon as ready to serve traffic.
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector tracks build and request metrics via Prometheus.
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a MetricsCollector with registered Prometheus metrics.
func (*MetricsCollector) Handler ¶
func (m *MetricsCollector) Handler() http.Handler
Handler returns the Prometheus metrics endpoint.
func (*MetricsCollector) RecordBuild ¶
func (m *MetricsCollector) RecordBuild(duration time.Duration)
RecordBuild records a successful build.
func (*MetricsCollector) RecordBuildFailure ¶
func (m *MetricsCollector) RecordBuildFailure()
RecordBuildFailure records a failed build.
func (*MetricsCollector) RecordCacheHit ¶
func (m *MetricsCollector) RecordCacheHit()
RecordCacheHit records a JIT cache hit.
func (*MetricsCollector) RecordCacheMiss ¶
func (m *MetricsCollector) RecordCacheMiss()
RecordCacheMiss records a JIT cache miss.
func (*MetricsCollector) RecordRequest ¶
func (m *MetricsCollector) RecordRequest(method, path string, duration time.Duration)
RecordRequest records an HTTP request.
type Options ¶
type Options struct {
SourceDir string
ConfigPath string // daemon.yaml path, optional
Port string
Bind string
TLSCert string
TLSKey string
Systemd bool
BuildDrafts bool
DisableWatch bool // disable file watching (default false)
BuildInterval time.Duration // periodic full rebuild interval (0 = disabled)
PluginDir string // plugin directory (default: <sourceDir>/plugins)
DisablePlugin bool // disable plugin loading
PluginRegistry *plugin.Registry // compiled plugins registry (optional)
ThemeManager *theme.Manager // theme manager (optional)
}
Options configures the daemon.
type Serving ¶
type Serving struct {
// contains filtered or unexported fields
}
Serving manages the HTTP server, static file serving, JIT rendering, and admin API.
func NewServing ¶
func NewServing(opts ServingOptions) *Serving
NewServing creates a new Serving instance.
func (*Serving) HandleCacheUpdated ¶
HandleCacheUpdated is called when the cache is updated.
type ServingOptions ¶
type ServingOptions struct {
OutputDir string
Bind string
Port string
TLSCert string
TLSKey string
AdminHandler http.Handler
JITCache *cache.JITCache
Builder *Builder
Bus eventbus.EventBus
Logf func(format string, args ...any)
Health *HealthChecker
Metrics *MetricsCollector
// ContentAPI is an optional read-only handler for /api/v1/* content
// queries. When non-nil, it is registered before the / catch-all so
// exact-prefix matches win over the static file fallback.
ContentAPI http.Handler
// SSEHub, if non-nil, enables the /api/v1/events real-time push endpoint.
SSEHub *sse.SSEHub
}
ServingOptions configures the Serving layer.
type SystemdNotifier ¶
type SystemdNotifier struct {
// contains filtered or unexported fields
}
SystemdNotifier integrates with systemd's sd_notify protocol. Phase 1: basic support. Phase 2: full sd_notify implementation.
func NewSystemdNotifier ¶
func NewSystemdNotifier(enabled bool) *SystemdNotifier
NewSystemdNotifier creates a SystemdNotifier. If enabled is true and NOTIFY_SOCKET env var is set, notifications are sent.
func (*SystemdNotifier) Status ¶
func (n *SystemdNotifier) Status(msg string)
Status sends a status message to systemd.
func (*SystemdNotifier) Stopping ¶
func (n *SystemdNotifier) Stopping()
Stopping sends STOPPING=1 to systemd.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches content/ and data/ for changes, then triggers rebuild.
func NewWatcher ¶
func NewWatcher(opts WatcherOptions) (*Watcher, error)
NewWatcher creates a new Watcher that recursively watches SourceDir.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contentindex provides an in-memory query index over the pre-built /api/{section}.json files.
|
Package contentindex provides an in-memory query index over the pre-built /api/{section}.json files. |
|
Package sse provides Server-Sent Events (SSE) push for the daemon.
|
Package sse provides Server-Sent Events (SSE) push for the daemon. |