storage

package
v6.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: GPL-3.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir() string

DataDir returns the lazily-initialized base directory.

func EnsureWritable

func EnsureWritable(path string) error

EnsureWritable makes sure directory exists and is writable.

func FormatDatabaseName added in v6.6.6

func FormatDatabaseName(dbName string) string

FormatDatabaseName converts internal database name to display name.

func GetAvailableDatabases added in v6.6.6

func GetAvailableDatabases() []string

GetAvailableDatabases returns the list of all available database names. This is the canonical source for database names used throughout the system.

func GetDatabaseDescription added in v6.6.6

func GetDatabaseDescription(dbName string) string

GetDatabaseDescription returns a human-readable description for a database.

func MetricsDir

func MetricsDir() string

func OutputDir

func OutputDir() string

Dir helpers (pure functions) derived from a base data directory.

func ReadDatabaseCSV

func ReadDatabaseCSV(name string) ([]string, error)

ReadDatabaseCSV extracts the named CSV file from the embedded .tar.gz and returns its lines.

func SeriesDir

func SeriesDir() string

func TestOnlyResetCacheManager

func TestOnlyResetCacheManager()

TestOnlyResetCacheManager resets cache manager singleton for testing isolation

func TestOnlyResetDataDir

func TestOnlyResetDataDir(flagVal string)

TestOnlyResetDataDir resets internal directory state (intended for tests).

Types

type CacheManager

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

CacheManager handles loading and building binary caches

func GetCacheManager

func GetCacheManager() *CacheManager

GetCacheManager returns the singleton cache manager

func (*CacheManager) GetDatabase

func (cm *CacheManager) GetDatabase(name string) (DatabaseIndex, error)

GetDatabase returns a database index, loading from cache or embedded resources

func (*CacheManager) InvalidateCache

func (cm *CacheManager) InvalidateCache() error

InvalidateCache removes cached files to force rebuild

func (*CacheManager) LoadOrBuild

func (cm *CacheManager) LoadOrBuild() error

LoadOrBuild ensures caches are loaded, building them if necessary

type DatabaseCache

type DatabaseCache struct {
	Version    string                   `json:"version"`    // Overall version
	Timestamp  int64                    `json:"timestamp"`  // Cache creation time
	Databases  map[string]DatabaseIndex `json:"databases"`  // Database name -> index
	Checksum   string                   `json:"checksum"`   // SHA256 of embedded tar.gz
	SourceHash string                   `json:"sourceHash"` // Hash of source data for validation
}

DatabaseCache holds all processed database indexes

type DatabaseIndex

type DatabaseIndex struct {
	Name    string           `json:"name"`    // Database name (e.g., "nouns")
	Version string           `json:"version"` // Version from CSV
	Records []DatabaseRecord `json:"records"` // All records
	Lookup  map[string]int   `json:"lookup"`  // Key -> record index mapping
}

DatabaseIndex provides fast access to database records

type DatabaseRecord

type DatabaseRecord struct {
	Key    string   `json:"key"`    // Primary identifier (e.g., "aardvark")
	Values []string `json:"values"` // All column values including version
}

DatabaseRecord represents a single row from a CSV database

Jump to

Keyboard shortcuts

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