managedtemp

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package managedtemp owns the private Unix filesystem namespace used by managed command temporary storage. It intentionally exposes no deletion primitives.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedVersion = errors.New("managedtemp: unsupported manifest version")

ErrUnsupportedVersion reports a record whose format cannot be safely read.

Functions

func ValidTestHomeMarker

func ValidTestHomeMarker(marker string) bool

ValidTestHomeMarker reports whether marker names a private command lease created by this protocol. It rejects ordinary paths and malformed metadata; test-home uses it before placing process-wide HOME state under the lease.

Types

type Lease

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

Lease is one locked command or job allocation. Its path is adapter-internal.

func (*Lease) Close

func (l *Lease) Close() error

Close releases the active lease lock without removing the allocation.

func (*Lease) ID

func (l *Lease) ID() string

ID returns the opaque 96-bit random allocation ID.

func (*Lease) Path

func (l *Lease) Path() string

Path returns the adapter-local allocation path.

func (*Lease) Remove

func (l *Lease) Remove() error

Remove validates that the parent still names the retained lease handle, then traverses that handle without following links.

func (*Lease) Started

func (l *Lease) Started(pid int) error

Started records the process identity after the runner successfully starts its dedicated process group.

func (*Lease) TempDir

func (l *Lease) TempDir() string

TempDir returns the private temporary directory supplied to the command.

func (*Lease) Terminal

func (l *Lease) Terminal() error

Terminal records that the runner has joined its direct command process. A still-live process group is retained for the reaper; a gone group may be removed immediately by the runner.

type Namespace

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

Namespace is a private managed root. Every mutation is relative to root.

func Open

func Open(path string) (*Namespace, error)

Open creates or adopts an absolute managed root. Existing objects are never chmodded: ownership, type, link, and mode must already be private.

func (*Namespace) Close

func (n *Namespace) Close() error

Close releases the root handle. It does not delete managed data.

func (*Namespace) OpenWorkspace

func (n *Namespace) OpenWorkspace(backend, identity, canonicalPath string) (*Workspace, error)

OpenWorkspace creates or adopts the private namespace for one transient workspace identity. The digest key, never the raw identity, is used in the path. canonicalPath is retained only in the owner-readable manifest for operator diagnosis.

func (*Namespace) Path

func (n *Namespace) Path() string

Path returns the root path for adapter-internal composition only.

func (*Namespace) ReadSweepCompletion

func (n *Namespace) ReadSweepCompletion() (time.Time, error)

ReadSweepCompletion reads the durable sweep record without changing it.

func (*Namespace) Sweep

func (n *Namespace) Sweep(ctx context.Context, opts SweepOptions) (SweepResult, error)

Sweep performs one non-blocking, root-coordinated recovery pass. It never waits for an active command's lease lock and only removes validated leases.

func (*Namespace) WritePrivateFile

func (n *Namespace) WritePrivateFile(name string, data []byte) error

WritePrivateFile creates a private root-level protocol record atomically.

type SweepOptions

type SweepOptions struct {
	Now              time.Time
	Interval         time.Duration
	CommandReapAfter time.Duration
}

SweepOptions controls one bounded, interval-gated recovery pass. Now is supplied by composition so tests and scheduled maintenance are deterministic.

type SweepResult

type SweepResult struct {
	Scanned bool
	Deleted int
}

SweepResult reports whether this caller scanned rather than observing a recent completion or another process's root sweep lock.

type Workspace

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

Workspace is one private workspace namespace below a Namespace.

func (*Workspace) Allocate

func (w *Workspace) Allocate(kind string) (*Lease, error)

Allocate creates and locks a private cmd or job lease before publishing its manifest.

func (*Workspace) Close

func (w *Workspace) Close() error

Close releases the workspace handle. It does not delete managed data.

func (*Workspace) CreatePrivateFile

func (w *Workspace) CreatePrivateFile(name string, _ []byte) error

CreatePrivateFile creates an empty private file below the workspace.

func (*Workspace) Path

func (w *Workspace) Path() string

Path returns the adapter-local path of the private workspace namespace.

func (*Workspace) WritePrivateFile

func (w *Workspace) WritePrivateFile(name string, data []byte) error

WritePrivateFile creates a private file atomically. It refuses an existing target rather than changing its mode or treating it as managed state.

Jump to

Keyboard shortcuts

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