storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreating = "creating"
	StatusReady    = "ready"
)

Variables

View Source
var (
	ErrNotFound     = errors.New("database not found")
	ErrInvalidLabel = errors.New("invalid label")
	ErrClosed       = errors.New("store is closed")
)

Functions

This section is empty.

Types

type Database

type Database struct {
	Record
	Path string
	Pool *sqlite.Pool
}

Database is a ready runtime entry with an open pool.

func (*Database) Details

func (d *Database) Details() Details

Details returns inspect metadata including password.

func (*Database) Summary

func (d *Database) Summary() Summary

Summary returns list metadata without password.

type Details

type Details struct {
	Name      string    `json:"name"`
	Label     string    `json:"label,omitempty"`
	Username  string    `json:"username"`
	Password  string    `json:"password,omitempty"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

Details is an inspect/create response that may include credentials.

type Record

type Record struct {
	Name      string    `json:"name"`
	Label     string    `json:"label,omitempty"`
	Username  string    `json:"username"`
	Password  string    `json:"password,omitempty"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

Record is the durable metadata for a managed database.

type Store

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

Store owns management.db and ready tenant database pools.

func Open

func Open(config StoreConfig) (*Store, error)

Open creates or opens the storage root and loads ready databases.

func (*Store) Close

func (s *Store) Close() error

Close closes all tenant pools and the management database.

func (*Store) Create

func (s *Store) Create(label string) (*Database, error)

Create provisions a new tenant database.

func (*Store) Export added in v0.1.1

func (s *Store) Export(name string) (string, error)

Export returns the filesystem path of the named database's SQLite file.

func (*Store) Get

func (s *Store) Get(name string) (*Database, error)

Get returns a ready database by generated name.

func (*Store) GetByUsername

func (s *Store) GetByUsername(username string) (*Database, error)

GetByUsername returns a ready database by MySQL username.

func (*Store) Import added in v0.1.1

func (s *Store) Import(label string, fileData []byte) (*Database, error)

Import writes a user-supplied SQLite file into the storage root, validates it can be opened, registers it in the management catalog, and returns the new database entry.

func (*Store) List

func (s *Store) List() ([]Summary, error)

List returns ready database summaries without passwords.

func (*Store) Query added in v0.1.1

func (s *Store) Query(name string, query string) ([]string, [][]any, error)

Query executes an arbitrary SQL statement against the named database and returns column names and rows. The connection is opened unrestricted so power users can run any statement including PRAGMAs.

func (*Store) Root

func (s *Store) Root() string

Root returns the absolute storage root.

func (*Store) Stats

func (s *Store) Stats() map[string]sql.DBStats

Stats returns per-database pool stats.

type StoreConfig

type StoreConfig struct {
	Root        string
	WALMode     bool
	BusyTimeout time.Duration
	MaxConns    int
}

StoreConfig configures the storage root and per-database pools.

type Summary

type Summary struct {
	Name      string    `json:"name"`
	Label     string    `json:"label,omitempty"`
	Username  string    `json:"username"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

Summary is a list view without credentials.

Jump to

Keyboard shortcuts

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