profilesvc

package
v0.131.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package profilesvc holds the live editing-profile set: the shipped defaults overlaid with a deployment's blob-persisted overrides, editable at runtime. Every override is run through profiles.Parse (the "framework test") before it is stored, so a structurally-bad profile is rejected at the API and can never reach the set the editor and op-builder read from. Overrides live in the blob store (durable across restarts, like vocabulary snapshots), keyed by profile id under Prefix.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound reports that no profile (or no override) exists for an id.
	ErrNotFound = errors.New("profilesvc: not found")
	// ErrInvalid wraps a profiles.Parse failure on a save.
	ErrInvalid = errors.New("profilesvc: invalid profile")
	// ErrIDMismatch reports that a saved profile's id differs from its path id.
	ErrIDMismatch = errors.New("profilesvc: profile id does not match path")
	// ErrConflict reports a lost optimistic-lock race on save.
	ErrConflict = errors.New("profilesvc: version conflict")
	// ErrReadOnly reports a mutation attempted without a blob store.
	ErrReadOnly = errors.New("profilesvc: no blob store; profiles are read-only")
)

Functions

This section is empty.

Types

type ListEntry

type ListEntry struct {
	Profile    *profiles.Profile
	Overridden bool
}

ListEntry pairs a profile with whether an override currently shadows it, read from one snapshot so the pair is always coherent.

type Service

type Service struct {
	Blob   blob.Store
	Prefix string
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Service owns the active profile set. The zero value is unusable; construct with New. A nil Blob yields a defaults-only, read-only service.

func New

func New(bs blob.Store, prefix string, logger *slog.Logger) *Service

New builds the service over blob (nil for defaults-only) rooted at prefix.

func (*Service) DeleteOverride

func (s *Service) DeleteOverride(ctx context.Context, id string) error

DeleteOverride removes id's blob override and reloads, reverting to the shipped default (or dropping the profile if it had none). ErrNotFound when no override exists.

func (*Service) Get

func (s *Service) Get(id string) (p *profiles.Profile, etag string, overridden bool, err error)

Get returns the active profile for id, its override etag ("" when the profile is the shipped default), and whether it is overridden.

func (*Service) List

func (s *Service) List() []ListEntry

List returns every profile with its override state, from one coherent snapshot (so the overridden flag always matches the returned profile).

func (*Service) Load

func (s *Service) Load(ctx context.Context) error

Load builds the initial set: the embedded defaults overlaid with the blob overrides. It is Reload, exposed under a boot-friendly name.

func (*Service) Mapper

func (s *Service) Mapper() *editor.Mapper

Mapper builds the read/op mapper from the live set, so record rendering and batch ops follow runtime edits to the work and instance profiles.

func (*Service) Overridden

func (s *Service) Overridden(id string) bool

Overridden reports whether id currently has a blob override.

func (*Service) Put

func (s *Service) Put(ctx context.Context, id string, data []byte, ifMatch string) (string, error)

Put validates data, persists it as id's override under optimistic locking, then reloads the set. An empty ifMatch means create-only (the first override of a default, or a brand-new profile); a non-empty ifMatch requires the stored override to still carry that etag. Returns the new etag.

func (*Service) Reload

func (s *Service) Reload(ctx context.Context) error

Reload rebuilds the active set from the embedded defaults and the current blob overrides. A malformed override is logged and skipped so one bad blob cannot brick the whole set (or boot); a broken embedded default is a programmer error and fails hard.

func (*Service) Set

func (s *Service) Set() profiles.Set

Set returns the active profiles keyed by id. The map is the live snapshot and must be treated as read-only.

Jump to

Keyboard shortcuts

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