Documentation
¶
Index ¶
- Constants
- func MigrationPlan() migrate.Plan
- func SanitizeName(name string) string
- func ValidateName(name string) error
- type Session
- type Store
- func (s *Store) Backup() (string, error)
- func (s *Store) Delete(name string) error
- func (s *Store) DeleteAll() error
- func (s *Store) Get(name string) (*Session, error)
- func (s *Store) List() ([]*Session, error)
- func (s *Store) Names() ([]string, error)
- func (s *Store) Rename(oldName, newName string) error
- func (s *Store) Save(sess *Session) error
- func (s *Store) UpdateAttached(name string) error
- func (s *Store) UpdateHealth(name, status string) error
- func (s *Store) UpdateMode(name, mode string) error
Constants ¶
const SchemaVersion = 1
SchemaVersion is the current on-disk schema version of sessions.json. Bump this and append a Step to the Plan returned by MigrationPlan() whenever the shape of diskData or Session changes in a non-additive way.
Variables ¶
This section is empty.
Functions ¶
func MigrationPlan ¶
MigrationPlan returns the migrate.Plan for sessions.json. Steps is empty at v1 because the initial migration only stamps the version — no content changes are required to turn an unversioned sessions.json into v1.
func SanitizeName ¶
SanitizeName converts a string into a valid session name by replacing invalid characters with dashes and trimming.
func ValidateName ¶
ValidateName returns an error if name is not a valid session name.
Types ¶
type Session ¶
type Session struct {
Name string `json:"name"`
UUID string `json:"uuid"`
Mode string `json:"mode"`
Workdir string `json:"workdir"`
CreatedAt time.Time `json:"created_at"`
LastAttachedAt time.Time `json:"last_attached_at,omitempty"`
LastHealthStatus string `json:"last_health_status,omitempty"`
LastHealthAt time.Time `json:"last_health_at,omitempty"`
}
Session holds metadata for a managed tmux session.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages session persistence via a JSON file with flock-based locking.
func (*Store) Backup ¶
Backup copies sessions.json to sessions.json.bak.<timestamp> and returns the backup path. It acquires the store lock for the duration of the read.
func (*Store) DeleteAll ¶
DeleteAll removes all sessions. It automatically creates a backup first so the user can recover from an accidental killall.
func (*Store) UpdateAttached ¶
UpdateAttached updates the last attached timestamp of a session.
func (*Store) UpdateHealth ¶
UpdateHealth updates the health status and timestamp of a session.
func (*Store) UpdateMode ¶
UpdateMode changes the mode of a session.