Go API documentation
github.com/rotari-dev/rotari/internal/basedirregistry
Overview
package basedirregistry // import "github.com/rotari-dev/rotari/internal/basedirregistry"
Package basedirregistry indexes state directories for discovery.
Functions
func Discover(masterDir string) (baseDirs []string, fromRuns bool, err error)
Discover lists the basedirs registered under masterDir without writing.
A master directory from before the basedir registry existed has only run
records; their basedirs are listed instead and fromRuns is set, so that a
caller allowed to write can register them.
func Find(masterDir, ref string) (string, error)
Find returns the basedir registered under masterDir whose Ref is ref,
as Discover lists them.
func Ref(baseDir string) string
Ref returns a short, stable reference to an absolute baseDir: the key of its
registry record. It names a basedir without revealing its path.
Types
type Registry struct {
// Has unexported fields.
}
Registry stores one discovery record per basedir under a master directory.
func Default() (Registry, error)
Default returns the registry under the resolved master directory.
func Open(masterDir string) Registry
Open returns the basedir registry under masterDir.
func (registry Registry) BaseDirs() ([]string, error)
BaseDirs lists registered basedirs. Missing or malformed records are
skipped.
func (registry Registry) Missing() ([]string, error)
Missing returns registered basedirs whose directories no longer exist.
func (registry Registry) Register(baseDir string) error
Register adds baseDir to the discovery index. Registration is idempotent.
func (registry Registry) Remove(baseDir string) (bool, error)
Remove unregisters baseDir if its record still refers to that exact path.