storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 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) 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) List

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

List returns ready database summaries without passwords.

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