Documentation
¶
Overview ¶
ABOUTME: In-memory render cache that wraps a DOT rendering function with sha256-keyed caching. ABOUTME: Supports TTL-based expiry, concurrent access, and manual cache clearing.
ABOUTME: Converts attractor Graph structures to DOT text and renders to SVG/PNG via graphviz. ABOUTME: Provides ToDOT, ToDOTWithStatus (with execution status color overlay), and Render functions.
Index ¶
- Constants
- func GraphvizAvailable() bool
- func Render(ctx context.Context, g *attractor.Graph, format string) ([]byte, error)
- func RenderDOTSource(ctx context.Context, dotText string, format string) ([]byte, error)
- func ToDOT(g *attractor.Graph) string
- func ToDOTWithStatus(g *attractor.Graph, outcomes map[string]*attractor.Outcome) string
- type RenderCache
- type RenderFunc
Constants ¶
const ( StatusColorSuccess = "#4CAF50" // green StatusColorFailed = "#F44336" // red StatusColorRunning = "#FFC107" // yellow StatusColorPending = "#9E9E9E" // gray )
Status color constants used for node fill colors in status overlay rendering.
Variables ¶
This section is empty.
Functions ¶
func GraphvizAvailable ¶
func GraphvizAvailable() bool
GraphvizAvailable checks whether the graphviz dot command is installed and reachable.
func Render ¶
Render produces rendered output from a Graph in the specified format. Supported formats: "dot" (returns DOT text), "svg", "png" (shell out to graphviz dot command). Returns an error if the format is unsupported or graphviz is not installed for svg/png.
func RenderDOTSource ¶
RenderDOTSource takes raw DOT text and renders it to the specified format (svg, png). For "dot" format, it returns the input text as-is. This is useful when the DOT text has been augmented (e.g. with status colors) and should not be re-parsed before rendering.
func ToDOT ¶
ToDOT serializes an attractor Graph back into valid DOT digraph text. Node order is deterministic (sorted by ID) for reproducible output.
func ToDOTWithStatus ¶
ToDOTWithStatus serializes a Graph to DOT text with color overlays based on execution status. Nodes with outcomes are colored: green for success/partial_success, red for fail, yellow for retry (running), and gray for pending (no outcome or skipped).
Types ¶
type RenderCache ¶
type RenderCache struct {
// contains filtered or unexported fields
}
RenderCache wraps a DOT rendering function with an in-memory cache. Cache keys are derived from the sha256 hash of the DOT content combined with the format. Entries expire after the configured TTL.
func NewRenderCache ¶
func NewRenderCache(renderFn RenderFunc, ttl time.Duration) *RenderCache
NewRenderCache creates a RenderCache wrapping the given rendering function. Cached entries expire after the specified TTL duration.
func (*RenderCache) Len ¶
func (c *RenderCache) Len() int
Len returns the number of entries currently in the cache (including expired ones).
func (*RenderCache) RenderDOTSource ¶
func (c *RenderCache) RenderDOTSource(ctx context.Context, dotText string, format string) ([]byte, error)
RenderDOTSource renders DOT text to the specified format, returning cached results when available and not expired. Errors are never cached.