persistence

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package persistence provides session marker storage abstractions. This decouples session management from filesystem operations, improving testability and enabling alternative storage backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileMarkerStore

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

FileMarkerStore implements SessionMarkerStore using the local filesystem. Markers are stored as empty files with a .lock extension.

func NewDefaultFileMarkerStore

func NewDefaultFileMarkerStore() *FileMarkerStore

NewDefaultFileMarkerStore creates a FileMarkerStore in the default location. Uses ~/.hotplex/sessions on success, falls back to temp directory on failure.

func NewFileMarkerStore

func NewFileMarkerStore(markerDir string) (*FileMarkerStore, error)

NewFileMarkerStore creates a new FileMarkerStore with the given base directory. If the directory doesn't exist, it will be created.

func (*FileMarkerStore) Create

func (s *FileMarkerStore) Create(sessionID string) error

Create creates a session marker file.

func (*FileMarkerStore) Delete

func (s *FileMarkerStore) Delete(sessionID string) error

Delete removes a session marker file.

func (*FileMarkerStore) Dir

func (s *FileMarkerStore) Dir() string

Dir returns the marker directory path.

func (*FileMarkerStore) Exists

func (s *FileMarkerStore) Exists(sessionID string) bool

Exists checks if a session marker file exists.

type InMemoryMarkerStore

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

InMemoryMarkerStore implements SessionMarkerStore using an in-memory map. Useful for testing and scenarios where persistence is not required.

func NewInMemoryMarkerStore

func NewInMemoryMarkerStore() *InMemoryMarkerStore

NewInMemoryMarkerStore creates a new InMemoryMarkerStore.

func (*InMemoryMarkerStore) Create

func (s *InMemoryMarkerStore) Create(sessionID string) error

Create creates a session marker in memory.

func (*InMemoryMarkerStore) Delete

func (s *InMemoryMarkerStore) Delete(sessionID string) error

Delete removes a session marker from memory.

func (*InMemoryMarkerStore) Dir

func (s *InMemoryMarkerStore) Dir() string

Dir returns an empty string for in-memory store.

func (*InMemoryMarkerStore) Exists

func (s *InMemoryMarkerStore) Exists(sessionID string) bool

Exists checks if a session marker exists in memory.

type SessionMarkerStore

type SessionMarkerStore interface {
	// Exists checks if a session marker exists for the given session ID.
	Exists(sessionID string) bool

	// Create creates a session marker for the given session ID.
	// Returns an error if the marker cannot be created.
	Create(sessionID string) error

	// Delete removes the session marker for the given session ID.
	// Returns an error if the marker cannot be deleted.
	Delete(sessionID string) error

	// Dir returns the base directory where markers are stored.
	Dir() string
}

SessionMarkerStore defines the interface for session marker persistence. Session markers are used to track whether a CLI session can be resumed (e.g., Claude Code's --resume functionality).

Jump to

Keyboard shortcuts

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