record

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Draft

type Draft struct {
	Name    string
	Enabled bool
	Data    json.RawMessage
}

type Mode

type Mode string
const (
	ModeLinked Mode = "linked"
	ModePinned Mode = "pinned"
)

type Policy

type Policy interface {
	Derive(
		ctx context.Context,
		value root.Root,
		occurrence catalog.Occurrence,
		def definition.Definition,
	) (Draft, bool, []artifactstore.Diagnostic)
}

type Reconciler

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

func NewReconciler

func NewReconciler(
	ids artifactstore.IDGenerator,
	clock artifactstore.Clock,
) (*Reconciler, error)

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(
	ctx context.Context,
	rootValue root.Root,
	occurrences []catalog.Occurrence,
	existing []Record,
	definitions definition.Reader,
	policy Policy,
) (Reconciliation, error)

type Reconciliation

type Reconciliation struct {
	Creates     []Record
	Updates     []SourceStateUpdate
	Diagnostics []artifactstore.Diagnostic
}

type Record

type Record struct {
	ID                 artifactstore.RecordID     `json:"id"`
	RootID             artifactstore.RootID       `json:"rootID"`
	Occurrence         catalog.OccurrenceKey      `json:"occurrence"`
	Kind               artifactstore.ArtifactKind `json:"kind"`
	Name               string                     `json:"name"`
	Enabled            bool                       `json:"enabled"`
	Mode               Mode                       `json:"mode"`
	PinnedDefinition   *artifactstore.Digest      `json:"pinnedDefinition,omitempty"`
	ResolvedDefinition *artifactstore.Digest      `json:"resolvedDefinition,omitempty"`
	Data               json.RawMessage            `json:"data"`
	State              State                      `json:"state"`
	Diagnostics        []artifactstore.Diagnostic `json:"diagnostics,omitempty"`
	Revision           uint64                     `json:"revision"`
	CreatedAt          time.Time                  `json:"createdAt"`
	ModifiedAt         time.Time                  `json:"modifiedAt"`
}

func (Record) Validate

func (r Record) Validate() error

type Repository

type Repository interface {
	Get(
		ctx context.Context,
		id artifactstore.RecordID,
	) (Record, error)

	ListByRoot(
		ctx context.Context,
		rootID artifactstore.RootID,
	) ([]Record, error)

	Update(
		ctx context.Context,
		value Record,
		expectedRevision uint64,
	) error

	Delete(
		ctx context.Context,
		id artifactstore.RecordID,
		expectedRevision uint64,
	) error
}

type Service

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

func NewService

func NewService(
	repository Repository,
	definitions definition.Reader,
	clock artifactstore.Clock,
) (*Service, error)

func (*Service) Delete

func (s *Service) Delete(
	ctx context.Context,
	id artifactstore.RecordID,
	expectedRevision uint64,
) error

func (*Service) Follow

func (s *Service) Follow(
	ctx context.Context,
	id artifactstore.RecordID,
	expectedRevision uint64,
) (Record, error)

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	id artifactstore.RecordID,
) (Record, error)

func (*Service) ListByRoot

func (s *Service) ListByRoot(
	ctx context.Context,
	rootID artifactstore.RootID,
) ([]Record, error)

func (*Service) Pin

func (s *Service) Pin(
	ctx context.Context,
	id artifactstore.RecordID,
	expectedRevision uint64,
	digest artifactstore.Digest,
) (Record, error)

func (*Service) SetEnabled

func (s *Service) SetEnabled(
	ctx context.Context,
	id artifactstore.RecordID,
	expectedRevision uint64,
	enabled bool,
) (Record, error)

type SourceStateUpdate

type SourceStateUpdate struct {
	RecordID           artifactstore.RecordID
	RootID             artifactstore.RootID
	ResolvedDefinition *artifactstore.Digest
	State              State
	Diagnostics        []artifactstore.Diagnostic
	Revision           uint64
	ModifiedAt         time.Time
	ExpectedRevision   uint64
}

SourceStateUpdate is the source-derived subset of a record update.

Refresh may update this state, but must not alter record-owned fields such as name, enabled state, mode, local data, or pinning.

func (SourceStateUpdate) Validate

func (u SourceStateUpdate) Validate() error

type State

type State string
const (
	StateAvailable    State = "available"
	StateStale        State = "stale"
	StateMissing      State = "missing"
	StateInvalid      State = "invalid"
	StateIncompatible State = "incompatible"
)

Jump to

Keyboard shortcuts

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