publishing

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package publishing accepts one archive and its catalog metadata as a durable, resumable publishing operation. Storage transfers still use the media module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

Archive declares the complete ZIP before any upload is authorized.

type Authority

type Authority interface {
	Capture(context.Context, access.Actor) (json.RawMessage, error)
	Resume(context.Context, json.RawMessage) (access.Actor, error)
}

Authority captures only provider-owned, nonsecret delegation data. Resume checks the original credential and its current permissions. A serialized auth.Verified, arbitrary identity, or bearer token is never a delegation. Nil means automatic publication is unavailable to external callers.

type CompleteRequest

type CompleteRequest struct{}

CompleteRequest accepts the operation's already-declared archive. No caller may substitute another blob, content ID, or metadata at completion time.

type EntityReference

type EntityReference struct {
	ID       string           `json:"id,omitempty"`
	Kind     string           `json:"kind,omitempty"`
	Name     string           `json:"name,omitempty"`
	Language string           `json:"language,omitempty"`
	Scope    *EntityReference `json:"scope,omitempty"`
}

EntityReference selects a group by ID or an exact localized name. Scope selects the parent kind required by the configured group kind.

type EntityResolution

type EntityResolution struct {
	ID      string            `json:"id"`
	Kind    string            `json:"kind"`
	Name    string            `json:"name"`
	Created bool              `json:"created"`
	Scope   *EntityResolution `json:"scope,omitempty"`
}

EntityResolution identifies the canonical entity associated with this submission. Created remains true on every replay of the operation that created it. Scope reports an automatically resolved parent when needed.

type Mode

type Mode string

Mode is the result requested after the archive has been processed.

const (
	Draft     Mode = "draft"
	WhenReady Mode = "when_ready"
)

type Operation

type Operation struct {
	ID        string              `json:"id"`
	State     State               `json:"state"`
	ContentID string              `json:"content_id"`
	VersionID string              `json:"version_id"`
	PublishAt *time.Time          `json:"publish_at,omitempty"`
	Entities  []EntityResolution  `json:"entities"`
	Progress  Progress            `json:"progress"`
	Result    *OperationResult    `json:"result,omitempty"`
	Error     *OperationError     `json:"error,omitempty"`
	Upload    *media.PresignReply `json:"upload,omitempty"`
	CreatedAt time.Time           `json:"created_at"`
	UpdatedAt time.Time           `json:"updated_at"`
}

Operation is the durable receipt. Upload appears only on Put, never Get.

type OperationError

type OperationError struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Retryable bool   `json:"retryable"`
	Field     string `json:"field,omitempty"`
}

OperationError describes a refused request or a stopped asynchronous operation.

func (*OperationError) Error

func (f *OperationError) Error() string

type OperationResult

type OperationResult struct {
	Path  string `json:"path"`
	Pages int    `json:"pages"`
}

type Options

type Options struct {
	Pool      *pgxpool.Pool
	Schema    string
	Tenant    string
	Catalog   *catalog.Store
	Groups    *groups.Store
	Registry  *media.Registry
	Uploads   *media.Uploads
	Manifests *media.Manifests
	Versions  *versions.Service
	Auth      auth.Authenticator
	Authority Authority
	Logger    *slog.Logger
	Clock     func() time.Time
}

type Progress

type Progress struct {
	Stage     string `json:"stage"`
	Completed int    `json:"completed"`
	Total     int    `json:"total"`
}

type Request

type Request struct {
	Content               catalog.ContentInput `json:"content"`
	Entities              []EntityReference    `json:"entities,omitempty"`
	Archive               Archive              `json:"archive"`
	Publish               Mode                 `json:"publish,omitempty"`
	PublishAt             *time.Time           `json:"publish_at,omitempty"`
	CreateMissingEntities bool                 `json:"create_missing_entities,omitempty"`
	Source                *Source              `json:"source,omitempty"`
}

Request is immutable for an operation ID. One initial version is supported.

type Source

type Source struct {
	Provider string `json:"provider"`
	ID       string `json:"id"`
	URL      string `json:"url,omitempty"`
}

Source identifies an external record. URL is provenance, never a fetch URL.

type State

type State string
const (
	AwaitingUpload State = "awaiting_upload"
	Processing     State = "processing"
	Publishing     State = "publishing"
	Scheduled      State = "scheduled"
	Ready          State = "ready"
	ReviewRequired State = "review_required"
	Published      State = "published"
	Blocked        State = "blocked"
	Failed         State = "failed"
)

type Store

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

func New

func New(o Options) (*Store, error)

func (*Store) Complete

func (s *Store) Complete(ctx context.Context, actor access.Actor, id string) (Operation, error)

Complete accepts the bytes already uploaded by the caller. The exact commit ID and operation batch are retained, so a lost response or worker restart cannot import a second archive into this version.

func (*Store) Get

func (s *Store) Get(ctx context.Context, actor access.Actor, id string) (Operation, error)

Get is read-only. It never starts uploads, changes workflow state or publishes.

func (*Store) Handler

func (s *Store) Handler() http.Handler

func (*Store) Put

func (s *Store) Put(ctx context.Context, actor access.Actor, id string, in Request) (Operation, error)

Put creates an operation and its draft atomically, or resumes the same immutable request. It renews expired upload instructions without a new draft.

func (*Store) Reconcile

func (s *Store) Reconcile(ctx context.Context) error

Reconcile advances a bounded batch independently of HTTP traffic. Repeating it after a crash is safe; River's periodic contribution supplies recovery.

func (*Store) RiverJobs

func (s *Store) RiverJobs() riverhelpers.Contribution

RiverJobs joins the existing version queue. The durable operation table is the work source; a periodic reconciliation also recovers interrupted jobs.

Jump to

Keyboard shortcuts

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