Help us shape the future of Go! Take the 2026 Go Developer Survey

report

package
v1.4.33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package report is the OSS default implementation of core.ReportRenderer: a pure-Go, in-binary PNG "incidents analytics dashboard" renderer. It composes a fixed 1200x900 image with the Go standard library (image / image/draw / image/png) plus golang.org/x/image for font rasterization, using the compiled-in Go font (golang.org/x/image/font/gofont) — a []byte baked into the binary, NOT an external file.

This keeps the single-binary + air-gapped promise intact: no headless browser, no external process, no external font file, and no network. The only thing the report path ever sends over the wire is the channel upload itself (handled elsewhere). A branded / high-fidelity renderer is an enterprise concern installed behind the SAME core.ReportRenderer seam (services.SetReportRenderer); the API, channel delivery, and UI never change when the renderer is swapped.

Index

Constants

View Source
const (
	CardWidth  = 1200
	CardHeight = 900
)

Card dimensions. Fixed and bounded on purpose (a DoS/abuse guard as well as a layout simplification): a caller can never ask for an arbitrarily large canvas, so render cost is O(1) in the request. The dashboard is taller than the old single-incident card to fit the headline strip, the trend + severity charts, and the notable lists.

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer is the default pure-Go PNG card renderer. It parses the embedded Go font ONCE at construction; per-render font faces are created inside Render so concurrent renders never share a face's internal buffers (data- race safe under -race).

func NewRenderer

func NewRenderer() (*Renderer, error)

NewRenderer parses the compiled-in Go font and returns a ready renderer. It returns an error only if the embedded font bytes fail to parse, which would be a build-time defect, never a runtime/config condition.

func (*Renderer) Render

func (r *Renderer) Render(ctx context.Context, m core.ReportModel) (*core.ReportImage, error)

Render composes the dashboard card and encodes it to PNG. It never performs I/O beyond writing to an in-memory buffer, and is deterministic for a fixed model (no time.Now / map iteration / randomness in the draw path), so the "community binary is byte-for-byte the OSS card" guarantee holds.

Jump to

Keyboard shortcuts

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