jobcontent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package jobcontent owns content publication and durable job references.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed = errors.New("content_closed")
	ErrLimit  = errors.New("content_limit")
)
View Source
var (
	ErrInvalid  = errors.New("invalid_content")
	ErrNotFound = errors.New("content_not_found")
	ErrConflict = errors.New("content_conflict")
	ErrCorrupt  = errors.New("corrupt_content")
)

Functions

func ValidateClaims

func ValidateClaims(spec jobcontract.JobSpec, claims []Claim) error

ValidateClaims checks metadata correspondence only. Admission still requires manager-owned physical pins; callers cannot turn this validation into a pin.

Types

type AdmissionResources

type AdmissionResources interface {
	Prepare(context.Context, jobcontract.JobSpec) (PreparedResources, error)
}

AdmissionResources is called outside the Host mutex and database transaction.

type AssetResolver

type AssetResolver interface {
	Open(context.Context, string) (AssetStream, error)
}

type AssetStream

type AssetStream interface {
	io.ReadCloser
	Identity() jobcontract.ContentIdentity
	MediaType() string
}

type Claim

type Claim struct {
	Ref       string
	Object    ObjectIdentity
	MediaType string
}

func (Claim) Validate

func (claim Claim) Validate() error

type Dependencies

type Dependencies struct {
	Physical PhysicalStore
	Ledger   Ledger
	Limits   Limits
}

type Entry

type Entry struct {
	ID                string
	JobID             string
	Role              jobcontract.ContentRole
	Ref               string
	RunID             *string
	StoreID           string
	SHA256            string
	Size              int64
	MediaType         string
	Generation        *uint64
	State             EntryState
	FailureCode       *string
	LinkedAt          time.Time
	ReleasedByCommand *string
}

type EntryState

type EntryState string
const (
	EntryCapturing     EntryState = "capturing"
	EntryLive          EntryState = "live"
	EntryReleased      EntryState = "released"
	EntryCaptureFailed EntryState = "capture_failed"
)

type Generation

type Generation struct {
	Object    ObjectIdentity
	Number    uint64
	CreatedAt time.Time
}

func (Generation) Validate

func (generation Generation) Validate() error

type Inventory

type Inventory struct {
	JobID                string
	Revision             uint64
	SealedManifestSHA256 *string
	Entries              []Entry
}

type JobResources

type JobResources interface {
	Resolver() AssetResolver
	Close() error
}

type Ledger

type Ledger interface {
	RegisterContentStore(context.Context, Store) error
	// The bool identifies a new publication generation, not a new physical file.
	PublishContent(context.Context, Publication) (Generation, bool, error)
	ContentPublication(context.Context, string, string) (Generation, error)
	JobContent(context.Context, string) (Inventory, error)
}

Ledger contains metadata operations. Implementations never open or hash files.

type Limits

type Limits struct {
	Operations int
	Pins       int
	Borrowed   int
	Resources  int
}

func DefaultLimits

func DefaultLimits() Limits

type Manager

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

func New

func New(ctx context.Context, dependencies Dependencies) (*Manager, error)

func (*Manager) Close

func (manager *Manager) Close() error

func (*Manager) Prepare

func (manager *Manager) Prepare(
	ctx context.Context,
	spec jobcontract.JobSpec,
) (result PreparedResources, prepareErr error)

func (*Manager) Status

func (manager *Manager) Status() Status

func (*Manager) Upload

func (manager *Manager) Upload(
	ctx context.Context,
	identity jobcontract.ContentIdentity,
	body io.ReadCloser,
) (UploadResult, error)

Upload owns body, including failures before reading. Close must unblock Read; this is the cancellation contract required of the HTTP request body adapter.

func (*Manager) ValidatePermit

func (manager *Manager) ValidatePermit(permit *Permit, expectedSpecSHA256 string) ([]Claim, error)

ValidatePermit is deliberately lightweight. Prepare performed the physical verification; this validates its still-live private ownership without IO. File reads and new borrows additionally verify the current physical identity.

type ObjectIdentity

type ObjectIdentity struct {
	StoreID       string
	Content       jobcontract.ContentIdentity
	IncarnationID string
	WitnessSHA256 string
	ChangeToken   string
}

ObjectIdentity binds verified bytes to one private physical file incarnation. It is internal metadata, not proof that an untrusted caller owns a live pin.

func (ObjectIdentity) Validate

func (object ObjectIdentity) Validate() error

type Permit

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

Permit has no public constructor or writable evidence. It identifies a live resource owned by one Manager; copying Claims cannot create a permit.

type PhysicalStore

type PhysicalStore interface {
	Store() Store
	Ready(context.Context) error
	PutContent(context.Context, jobcontract.ContentIdentity, io.Reader) (bool, error)
	OpenPinned(context.Context, jobcontract.ContentIdentity) (PinnedContent, error)
}

PhysicalStore owns one private root. The runtime closes it after Manager.Close.

type PinnedContent

type PinnedContent interface {
	io.ReadSeekCloser
	Object() ObjectIdentity
	Check() error
}

PinnedContent retains a fully hashed file descriptor. Each open has its own offset; Object is immutable evidence, and Check verifies the live private file.

type PreparedResources

type PreparedResources interface {
	Claims() []Claim
	Permit() *Permit
	BindJob(string) (JobResources, error)
	Close() error
}

PreparedResources owns physical pins until BindJob succeeds or Close returns. Its metadata does not authorize admission without the owning manager permit.

type Publication

type Publication struct {
	Object ObjectIdentity
	At     time.Time
}

func (Publication) Validate

func (publication Publication) Validate() error

type Status

type Status struct {
	Operations int
	Pins       int
	Borrowed   int
	Resources  int
	Hashes     int
}

type Store

type Store struct {
	ID             string
	Kind           StoreKind
	InstallationID string
	CreatedAt      time.Time
}

func (Store) Validate

func (store Store) Validate() error

type StoreKind

type StoreKind string
const (
	StoreKindExecutor StoreKind = "executor"
	StoreKindCache    StoreKind = "cache"
)

type UploadResult

type UploadResult struct {
	PhysicalCreated bool
	Generation      Generation
}

Jump to

Keyboard shortcuts

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