factorysessions

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSessionID = "~default"

DefaultSessionID is the stable alias for the primary live factory session.

View Source
const ValidationReasonMissing = validationReasonMissing

ValidationReasonMissing reports that the session folder path does not exist.

View Source
const ValidationReasonNotDirectory = validationReasonNotDirectory

ValidationReasonNotDirectory reports that the session folder path is not a directory.

View Source
const ValidationReasonNotRunnable = validationReasonNotRunnable

ValidationReasonNotRunnable reports that the folder exposes no runnable factory targets.

View Source
const ValidationReasonRequired = validationReasonRequired

ValidationReasonRequired reports that a required session field was empty.

View Source
const ValidationReasonTargetNotFound = validationReasonTargetNotFound

ValidationReasonTargetNotFound reports that the requested target was not discovered.

View Source
const ValidationReasonUnreadable = validationReasonUnreadable

ValidationReasonUnreadable reports that the session folder could not be read.

View Source
const ValidationTargetKind = validationTargetKind

ValidationTargetKind is the API error-target kind for factory-session validation failures.

Variables

This section is empty.

Functions

func AbsolutizeFactoryDirectory

func AbsolutizeFactoryDirectory(dir string) (string, error)

AbsolutizeFactoryDirectory resolves and cleans a factory directory path.

func ExpandFolderHome

func ExpandFolderHome(path string) (string, error)

ExpandFolderHome expands a leading tilde in folder paths.

func FactoryName

func FactoryName(rootDir string, runtimeCfg *factoryconfig.LoadedFactoryConfig) factoryapi.FactoryName

FactoryName derives the API factory name for a session runtime config.

func ListSummaries

func ListSummaries(registry *Registry) []factoryapi.FactorySessionSummary

ListSummaries builds API session summaries from registered live sessions.

func NewSessionID

func NewSessionID() string

NewSessionID allocates a unique live session identifier.

func NewValidationError

func NewValidationError(reason string, field string, err error) error

NewValidationError builds a structured factory-session validation error.

func ResolveSessionFolder

func ResolveSessionFolder(folderPath string) (string, error)

ResolveSessionFolder validates and resolves a factory session folder path.

func SameFactoryDir

func SameFactoryDir(left, right string) bool

SameFactoryDir reports whether two factory directory paths refer to the same location.

func SessionFactoryRootDir

func SessionFactoryRootDir(serviceRootDir string, session *LiveSession) string

SessionFactoryRootDir resolves the editable-definition root for a live session.

func SummaryResponse

func SummaryResponse(session *LiveSession) factoryapi.FactorySessionSummary

SummaryResponse maps a live session to the API summary shape.

func TargetDisplayName

func TargetDisplayName(ref TargetRef) string

TargetDisplayName formats a target ref for operator-facing errors.

func TargetResponse

func TargetResponse(target Target) factoryapi.FactorySessionTarget

TargetResponse maps a discovered target to the API target shape.

func TargetsResponse

func TargetsResponse(targets []Target) []factoryapi.FactorySessionTarget

TargetsResponse maps discovered targets to API targets.

func ValidationReasonFromError

func ValidationReasonFromError(err error) (reason string, field string, ok bool)

ValidationReasonFromError returns the validation reason and field when err is a factory-session validation error.

Types

type LiveSession

type LiveSession struct {
	ID         string
	FactoryDir string
	FolderPath string
	Handle     any
	IsDefault  bool
	Project    string
	Target     TargetRef
}

LiveSession tracks one live factory session and its runtime handle. Handle is typed by the composition root (for example *service.liveRuntimeHandle).

func NewLiveSession

func NewLiveSession(
	sessionID string,
	factoryDir string,
	folderPath string,
	target TargetRef,
	handle any,
	isDefault bool,
	project string,
) *LiveSession

NewLiveSession constructs a registry entry for a started session.

type OpenResult

type OpenResult struct {
	SessionID       string
	Targets         []Target
	InitsNewFactory bool
	FolderPath      string
}

OpenResult is the internal outcome of opening or validating a session folder.

type Registry

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

Registry tracks live factory sessions and the selected session id.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty live session registry.

func (*Registry) Count

func (m *Registry) Count() int

Count returns the number of registered live sessions.

func (*Registry) Current

func (m *Registry) Current() *LiveSession

Current returns the selected live session when present.

func (*Registry) Get

func (m *Registry) Get(id string) *LiveSession

Get returns the live session for id when registered.

func (*Registry) IDs

func (m *Registry) IDs() []string

IDs returns registered session ids in sorted order.

func (*Registry) Remove

func (m *Registry) Remove(id string)

Remove deletes a live session and promotes another session when needed.

func (*Registry) Select

func (m *Registry) Select(id string) bool

Select marks an existing session as selected.

func (*Registry) Upsert

func (m *Registry) Upsert(session *LiveSession, selectSession bool)

Upsert registers or replaces a live session. When selectSession is true, or no session is currently selected, the session becomes selected.

type Target

type Target struct {
	Ref        TargetRef
	Label      string
	FolderPath string
	FactoryDir string
	Project    string
}

Target describes a runnable factory directory discovered under a session folder.

func BuildTargetFromConfig

func BuildTargetFromConfig(
	folderPath string,
	factoryDir string,
	ref TargetRef,
	projectName string,
) Target

BuildTargetFromConfig projects loaded factory config into a session target.

func CloneTargets

func CloneTargets(targets []Target) []Target

CloneTargets returns a defensive copy of discovered targets.

func DiscoverTargets

func DiscoverTargets(folderPath string, probe TargetProbe) ([]Target, error)

DiscoverTargets lists runnable factory targets under folderPath.

func SelectTarget

func SelectTarget(targets []Target, ref *TargetRef) (*Target, error)

SelectTarget chooses a discovered target from an optional explicit ref.

type TargetKind

type TargetKind string

TargetKind identifies whether a session target is the default factory or a named layout.

const (
	TargetKindDefault TargetKind = "default"
	TargetKindNamed   TargetKind = "named"
)

type TargetProbe

type TargetProbe func(folderPath string, factoryDir string, ref TargetRef) (Target, bool)

TargetProbe loads metadata for one discovered factory session target.

type TargetRef

type TargetRef struct {
	Kind TargetKind
	Name string
}

TargetRef selects a discovered factory session target.

Jump to

Keyboard shortcuts

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