package sessions import ( "errors" "fmt" "time" ) type Session struct { Id string Description string CreatedAt time.Time // Should be set to a zero time if the session is still active EndedAt time.Time } func (s *Session) ExistsFor() time.Duration { return time.Now().Sub(s.CreatedAt) } var ( ErrUnknownSession = errors.New("unknown session") ) type Storage interface { // List all sessions. GetAllSessions() ([]Session, error) // List all active sessions. GetActiveSessions() ([]Session, error) // List all past sessions. GetPastSessions() ([]Session, error) // Start a new session. StartSession(description string, createdAt time.Time) (Session, error) // End an old session. // Should update a session's [EndedAt] property. // Should return [ErrUnknownSession] if the session couldn't be found. EndSession(id string, endedAt time.Time) error // Delete a session. // Should return [ErrUnknownSession] if the session couldn't be found. DeleteSession(id string) error fmt.Stringer }