ollie/fs/session.go

24 lines
617 B
Go

// Package session builds the session/ file tree for the 9P namespace.
// The tree IS the session collection — rootState holds the sessions map.
// Package functions for lifecycle, lookup, and enumeration.
package fs
import ()
// Get returns the Session for id, or nil.
func Get(root *Tree, id string) *Session {
return Lookup(root, id)
}
// All returns all active sessions.
func All(root *Tree) []*Session {
rs := state(root)
rs.mu.RLock()
defer rs.mu.RUnlock()
sessions := make([]*Session, 0, len(rs.sessions))
for _, sess := range rs.sessions {
sessions = append(sessions, sess)
}
return sessions
}