Documentation
¶
Overview ¶
Package scripttiles keeps the tile each managed script is shown by in the scripts listing's grid view (#1909): its flow diagram (#1906), drawn by the tile worker (internal/platform/thumbworker) in the same headless browser every other tile is drawn in, light and dark.
A tile is keyed by the script and names the version it was drawn from, so saving a version owes a new one whatever the version changed. A version that does not parse is recorded as not drawable, with the parse error as the reason, and draws when a later version parses. Claiming, holding back and giving up follow the rules the worker applies to every other tile.
Index ¶
- Constants
- Variables
- func DarkKey(lightKey string) string
- func Key(prefix, scriptID, variant string) string
- type ObjectGetter
- type Orphan
- type Reader
- type Store
- func (s *Store) Claim(ctx context.Context, renderer int, lease time.Duration, limit int) ([]Work, error)
- func (s *Store) CurrentKey(ctx context.Context, scriptID string) (key string, current bool, err error)
- func (s *Store) Forget(ctx context.Context, scriptID string) error
- func (s *Store) Hold(ctx context.Context, scriptID string, hold time.Duration, attempts int) error
- func (s *Store) Orphans(ctx context.Context, limit int) ([]Orphan, error)
- func (s *Store) Record(ctx context.Context, scriptID string, version int, key string, renderer int) error
- func (s *Store) RecordFailure(ctx context.Context, scriptID string, version int, reason string) error
- type Work
Constants ¶
const ( VariantLight = "light" VariantDark = "dark" )
Variants of a tile.
Variables ¶
var ErrNoTile = errors.New("this script has no tile")
ErrNoTile is a script with no tile to serve: never drawn, or its current version is recorded as not drawable.
Functions ¶
Types ¶
type ObjectGetter ¶
type ObjectGetter interface {
GetObject(ctx context.Context, bucket, key string) ([]byte, string, error)
}
ObjectGetter reads one stored object.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader serves a script's stored tile.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the Postgres record of every script's tile.
func (*Store) Claim ¶
func (s *Store) Claim(ctx context.Context, renderer int, lease time.Duration, limit int) ([]Work, error)
Claim leases up to limit scripts owed a tile for lease, drawn by renderer generation renderer.
func (*Store) CurrentKey ¶
func (s *Store) CurrentKey(ctx context.Context, scriptID string) (key string, current bool, err error)
CurrentKey is the stored light tile of a script, unless its current version is recorded as not drawable: that script is shown by the placeholder, not by an older version's diagram. current is false while the stored tile is an older version's, the one a script shows until the worker draws the version it is at. The id is compared as text, so an id that is not a script's is no tile rather than a malformed query.
func (*Store) Hold ¶
Hold holds a script back from the next claim for hold after an attempt that did not finish.