storage

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStorage

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

FileStorage implements file-based session persistence

func NewFileStorage

func NewFileStorage(filePath string, syncInterval int, encryptSecrets bool) (*FileStorage, error)

NewFileStorage creates a new file storage instance

func (*FileStorage) Close

func (fs *FileStorage) Close() error

Close stops the sync routine and performs final sync

func (*FileStorage) Delete

func (fs *FileStorage) Delete(sessionID string) error

Delete removes a session and syncs to file

func (*FileStorage) Load

func (fs *FileStorage) Load(sessionID string) (*SessionData, error)

Load retrieves a session by ID

func (*FileStorage) LoadAll

func (fs *FileStorage) LoadAll() ([]*SessionData, error)

LoadAll retrieves all sessions

func (*FileStorage) Save

func (fs *FileStorage) Save(session *SessionData) error

Save stores a session and syncs to file

func (*FileStorage) Update

func (fs *FileStorage) Update(session *SessionData) error

Update updates an existing session

type MemoryStorage

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

MemoryStorage implements in-memory session storage

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage creates a new memory storage instance

func (*MemoryStorage) Close

func (m *MemoryStorage) Close() error

Close is a no-op for memory storage

func (*MemoryStorage) Delete

func (m *MemoryStorage) Delete(sessionID string) error

Delete removes a session from memory

func (*MemoryStorage) Load

func (m *MemoryStorage) Load(sessionID string) (*SessionData, error)

Load retrieves a session by ID

func (*MemoryStorage) LoadAll

func (m *MemoryStorage) LoadAll() ([]*SessionData, error)

LoadAll retrieves all sessions

func (*MemoryStorage) Save

func (m *MemoryStorage) Save(session *SessionData) error

Save stores a session in memory

func (*MemoryStorage) Update

func (m *MemoryStorage) Update(session *SessionData) error

Update updates an existing session

type SessionData

type SessionData struct {
	ID          string            `json:"id"`
	Port        int               `json:"port"`
	StartedAt   time.Time         `json:"started_at"`
	UserID      string            `json:"user_id"`
	Status      string            `json:"status"`
	Environment map[string]string `json:"environment"`
	Tags        map[string]string `json:"tags"`
	ProcessID   int               `json:"process_id,omitempty"` // For validation on recovery
	Command     []string          `json:"command,omitempty"`    // To recreate process if needed
	WorkingDir  string            `json:"working_dir,omitempty"`
}

SessionData represents the persistable session data

type Storage

type Storage interface {
	// Save persists a session to storage
	Save(session *SessionData) error

	// Load retrieves a session by ID
	Load(sessionID string) (*SessionData, error)

	// LoadAll retrieves all sessions
	LoadAll() ([]*SessionData, error)

	// Delete removes a session from storage
	Delete(sessionID string) error

	// Update updates an existing session
	Update(session *SessionData) error

	// Close cleans up any resources
	Close() error
}

Storage defines the interface for session persistence

func NewStorage

func NewStorage(config *StorageConfig) (Storage, error)

NewStorage creates a storage instance based on the configuration

type StorageConfig

type StorageConfig struct {
	Type string `json:"type"` // "memory", "file", "sqlite"

	// File storage config
	FilePath       string `json:"file_path,omitempty"`
	SyncInterval   int    `json:"sync_interval_seconds,omitempty"`
	EncryptSecrets bool   `json:"encrypt_sensitive_data,omitempty"`

	// Future: Database config
	DatabaseURL string `json:"database_url,omitempty"`
}

StorageConfig holds configuration for storage backends

Jump to

Keyboard shortcuts

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