Documentation
¶
Overview ¶
Package session manages per-invocation lifecycle: a unique session ID, the profile file path, and ordered cleanup hooks.
Index ¶
Constants ¶
const StaleProfileMaxAge = 1 * time.Hour
StaleProfileMaxAge bounds how old a leftover profile file can be before the next session.New() considers it abandoned and removes it. Profiles orphaned by SIGKILL of the parent ora process are cleaned up on the next invocation rather than waiting for `doctor --sweep`.
Variables ¶
This section is empty.
Functions ¶
func ListStaleProfiles ¶
ListStaleProfiles returns absolute paths of leftover ora profile files in dir that are older than maxAge. Used by both `ora doctor` (to display) and the per-session sweep (to remove); having one predicate keeps the two consumers from drifting.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session bundles a unique ID, the on-disk profile path, and ordered cleanup hooks. Cleanup is idempotent and runs all hooks in LIFO order.
func New ¶
func New() *Session
New initializes a session: assigns an ID and computes the profile path under ${TMPDIR}. As a side effect, sweeps any leftover ora profile files older than StaleProfileMaxAge to defend against SIGKILL leaks.
func (*Session) Cleanup ¶
Cleanup runs all registered hooks in LIFO order, then deletes the profile file. Safe to call concurrently — only the first invocation across all goroutines runs the hooks; subsequent calls return the same aggregated error.
func (*Session) OnCleanup ¶
OnCleanup registers a hook to run during Cleanup. Hooks run in LIFO order so resources started last are torn down first. Safe for concurrent use; calling OnCleanup AFTER Cleanup has started logs a warning and drops the hook (a programming error: lifecycle hooks should always be registered before triggering cleanup).
func (*Session) ProfilePath ¶
ProfilePath returns the absolute path the profile will be written to.
func (*Session) WriteProfile ¶
WriteProfile writes the Seatbelt profile content to ProfilePath with mode 0600 (only the user can read).