thumbdue

package
v1.147.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package thumbdue is what the thumbnail stores share about the rows the renderer must look at (#2084). A row of resources, portal_assets or portal_collections carries thumbnail_due_at: when its owed rule next needs evaluating, NULL once the rule said it is owed nothing. A trigger sets it on every write the renderer did not make (migration 000189), and the stores read only due rows, through a partial index, so the cost of asking for work follows the rows that changed rather than the size of the library.

What the trigger cannot see is the rule changing under rows nobody wrote: a new renderer generation, a changed source bound, a newly drawable type. Sweep marks a whole table due once per rule, in chunks, and records the rule it marked under in thumbnail_sweeps.

Index

Constants

View Source
const NotifyChannel = "thumbnail_due"

NotifyChannel is the channel the trigger notifies when a row becomes due.

Variables

This section is empty.

Functions

func Rule

func Rule(query string, args ...any) string

Rule is the fingerprint of an owed rule: its SQL and the values bound into it, each as the driver sends it (a bound array is a pointer, whose address would change the fingerprint on every call). Two rules with the same fingerprint pass the same rows.

func Sweep

func Sweep(ctx context.Context, db *sql.DB, table Table, rule string) (int64, error)

Sweep marks every row of table due when rule is not the one it was last swept under, and records rule. It returns how many rows it marked: zero when the table was already swept under rule, or when another replica holds the sweep's lock (that replica records it). A row already due keeps its time; a claimed or held row is made due now and is still not claimed until its lease or hold passes.

Types

type Table

type Table string

A Table is one table the renderer draws from. Its value is the table name, and each carries the advisory lock its sweep runs under.

const (
	Resources   Table = "resources"
	Assets      Table = "portal_assets"
	Collections Table = "portal_collections"
)

The tables the renderer draws from.

Jump to

Keyboard shortcuts

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