publish

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package publish carries approved queue decisions into the BIBFRAME grain store: editorial quads written under ETag optimistic concurrency, the advisory ingest lease, and the downstream rebuild trigger. The write discipline (read -> patch -> conditional put -> retry-from-fresh) is safe against concurrent editors and re-ingest because editorial statements are independent IRI-based quads and canonicalization dedups.

Index

Constants

This section is empty.

Variables

View Source
var ErrIngestActive = errors.New("publish: ingest lease held; publish deferred")

ErrIngestActive reports that the ingest lease is held: approvals stay queued (durable) and publishing retries after the lease expires.

Functions

func MutateGrain

func MutateGrain(ctx context.Context, st blob.Store, path string, mutate func(old []byte) ([]byte, error)) (etag string, err error)

MutateGrain applies mutate to the grain at path under ETag optimistic concurrency: read, transform, conditional put, retry from fresh on conflict. The exported CAS primitive record editing (tasks/037) and store-backed ingest share.

Types

type IndexUpdater added in v0.53.0

type IndexUpdater interface {
	Apply(grainPath, etag string, grain []byte)
	AppendFeed(ctx context.Context, paths ...string) error
}

IndexUpdater is the workindex.Index surface publish writes keep exact: Apply folds one written grain in, AppendFeed publishes the changed paths so other containers read-their-writes (mirrors batch.IndexUpdater).

type Lease

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

Lease is the advisory ingest lease: feed re-ingest holds it (identity resolution is single-flight), and the publisher defers -- never drops -- approved changes while it is held. Expiry is carried in the record body, not store TTL, because DynamoDB expires lazily.

func NewLease

func NewLease(db store.Store, name string, ttl time.Duration) *Lease

NewLease wires the lease with the given hold duration.

func (*Lease) Acquire

func (l *Lease) Acquire(ctx context.Context, holder string) (bool, error)

Acquire attempts to take the lease for holder. It returns false when another holder has it un-expired. Re-acquiring one's own live lease extends it.

func (*Lease) Heartbeat

func (l *Lease) Heartbeat(ctx context.Context, holder string) error

Heartbeat extends the holder's live lease.

func (*Lease) Held

func (l *Lease) Held(ctx context.Context) (string, bool, error)

Held reports the current live holder, if any.

func (*Lease) Release

func (l *Lease) Release(ctx context.Context, holder string) error

Release drops the lease if holder still owns it.

func (*Lease) SetClock

func (l *Lease) SetClock(now func() time.Time)

SetClock overrides the clock (tests).

type Publisher

type Publisher struct {
	Blob  blob.Store
	Queue *suggest.Service
	Vocab *vocab.Index
	// Trigger receives one grains-changed event per successful run
	// (nil = no notification).
	Trigger trigger.Notifier
	// Lease, when set, defers publishing while ingest holds it.
	Lease *Lease
	// Prefix is the grain tree root in the blob store ("" = repo-layout
	// paths straight from bibframe.GrainPath).
	Prefix string
	// Summaries, when set, is the shared maintained summary source
	// (workindex, tasks/109) tag promotion scans instead of a per-run
	// corpus walk; nil falls back to ScanSummaries.
	Summaries ingest.SummarySource
	// Index, when set, is kept exact for this publisher's own grain writes
	// -- the read-your-writes contract the single-record and batch paths
	// hold (tasks/195, tasks/203). Without it, tag promotions and approved
	// publishes wait out the workindex refresh TTL: invisible to work
	// search for up to 30s, and batch selections resolve against the
	// stale index meanwhile.
	Index  IndexUpdater
	Logger *slog.Logger
}

Publisher drains approved-unpublished queue items into grains.

func (*Publisher) PromoteTag

func (p *Publisher) PromoteTag(ctx context.Context, promo suggest.Promotion, actor string) (int, error)

PromoteTag executes an approved tag promotion (tasks/044): every Work carrying the tag gains the controlled subject (with its authority labels and hierarchy), its editorial lcat:tag is retracted, and the alias grain records lcat:tagAlias so the projector suppresses the residual feed tag where the term is present and future entries auto-suggest the term. Returns the number of Works rewritten.

func (*Publisher) PublishApproved

func (p *Publisher) PublishApproved(ctx context.Context, actor string) (Result, error)

PublishApproved drains the approved-unpublished worklist: per Work, all its approved terms land in one grain mutation; each mutation stamps the queue items with the resulting grain ETag and writes an audit entry.

type Result

type Result struct {
	Published int      `json:"published"`
	Skipped   int      `json:"skipped"`
	Paths     []string `json:"paths,omitempty"`
}

Result summarizes one publish run.

Jump to

Keyboard shortcuts

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