Documentation
¶
Overview ¶
Package codes writes the content-code registry (content_codes) for the packages that own content: contenturl for host content, taxonomy and content for ContentKit's own records. Codes are generated in Postgres (contentkit_content_code), so one generator serves runtime and migrations.
Index ¶
- Constants
- Variables
- func Drain(rows Rows, err error) error
- func Language(l string) (string, error)
- func Merge(ctx context.Context, q Querier, qs, tenant string, from, into Key) error
- func Put(ctx context.Context, q Querier, qs, tenant string, entries []Entry) (map[Key]string, error)
- func Slugify(s string) string
- func ValidSlug(s string) bool
- type Entry
- type Key
- type PgxQuerier
- type Querier
- type Rows
Constants ¶
const MaxSlug = 80
MaxSlug is the longest slug, in bytes (slugs are ASCII).
Variables ¶
Functions ¶
func Merge ¶
Merge makes from's code redirect to into's final code and re-points codes already redirected to from, so every redirect is one hop. ErrNotFound when either has no code; ErrConflict when into already redirects to from.
func Put ¶
func Put(ctx context.Context, q Querier, qs, tenant string, entries []Entry) (map[Key]string, error)
Put assigns a code to every entry without one and sets its slugs, in the caller's transaction; it returns every entry's code. qs is the quoted schema. Code collisions and, under READ COMMITTED, concurrent registrations of the same content are retried; stricter isolation levels report the latter as a serialization failure for the caller to retry.
Types ¶
type Entry ¶
Entry is one content record's slugs. Slugs nil keeps the stored per-language slugs; a non-nil map replaces them.
type PgxQuerier ¶
PgxQuerier is a pgx pool, connection or transaction.