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 ¶
- type Archive
- type Authority
- type CompleteRequest
- type EntityReference
- type EntityResolution
- type Mode
- type Operation
- type OperationError
- type OperationResult
- type Options
- type Progress
- type Request
- type Source
- type State
- type Store
- func (s *Store) Complete(ctx context.Context, actor access.Actor, id string) (Operation, error)
- func (s *Store) Get(ctx context.Context, actor access.Actor, id string) (Operation, error)
- func (s *Store) Handler() http.Handler
- func (s *Store) Put(ctx context.Context, actor access.Actor, id string, in Request) (Operation, error)
- func (s *Store) Reconcile(ctx context.Context) error
- func (s *Store) RiverJobs() riverhelpers.Contribution
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 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 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 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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Complete ¶
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) 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 ¶
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.