db

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDatabaseFilename

func DefaultDatabaseFilename() (string, error)

func FindServerInCatalogs added in v0.40.4

func FindServerInCatalogs(ctx context.Context, dao DAO, serverName string) (catalog.Server, error)

FindServerInCatalogs searches all catalogs in the database for a server by name. Returns the matching catalog.Server or an error if not found.

Types

type Catalog added in v0.28.0

type Catalog struct {
	Ref         string          `db:"ref"`
	Digest      string          `db:"digest"`
	Title       string          `db:"title"`
	Source      string          `db:"source"`
	LastUpdated *time.Time      `db:"last_updated"`
	Servers     []CatalogServer `db:"-"`
}

type CatalogDAO added in v0.28.0

type CatalogDAO interface {
	GetCatalog(ctx context.Context, ref string) (*Catalog, error)
	UpsertCatalog(ctx context.Context, catalog Catalog) error
	DeleteCatalog(ctx context.Context, ref string) error
	ListCatalogs(ctx context.Context) ([]Catalog, error)
}

type CatalogServer added in v0.28.0

type CatalogServer struct {
	ID         *int64   `db:"id" json:"id"`
	ServerType string   `db:"server_type" json:"server_type"`
	Tools      ToolList `db:"tools" json:"tools"`
	Source     string   `db:"source" json:"source"`
	Image      string   `db:"image" json:"image"`
	Endpoint   string   `db:"endpoint" json:"endpoint"`
	CatalogRef string   `db:"catalog_ref" json:"catalog_ref"`

	Snapshot *ServerSnapshot `db:"snapshot" json:"snapshot"`
}

type DAO

type DAO interface {
	WorkingSetDAO
	CatalogDAO
	MigrationStatusDAO
	PullRecordDAO

	// Normally unnecessary to call this
	Close() error
}

func New

func New(opts ...Option) (DAO, error)

type MigrationStatus added in v0.29.0

type MigrationStatus struct {
	ID          *int64     `db:"id"`
	Status      string     `db:"status"`
	Logs        string     `db:"logs"`
	LastUpdated *time.Time `db:"last_updated"`
}

type MigrationStatusDAO added in v0.29.0

type MigrationStatusDAO interface {
	GetMigrationStatus(ctx context.Context) (*MigrationStatus, error)
	TryAcquireMigration(ctx context.Context, status string) (*MigrationStatus, bool, error)
	UpdateMigrationStatus(ctx context.Context, status MigrationStatus) error
}

type Option

type Option func(o *options) error

func WithDatabaseFile

func WithDatabaseFile(dbFile string) Option

func WithMigrations added in v0.39.2

func WithMigrations(filesystem fs.FS, path string) Option

type PullRecord added in v0.37.0

type PullRecord struct {
	ID          *int64     `db:"id"`
	Ref         string     `db:"ref"`
	FirstPulled *time.Time `db:"first_pulled"`
}

type PullRecordDAO added in v0.37.0

type PullRecordDAO interface {
	RecordPull(ctx context.Context, ref string) error
	CheckPullRecord(ctx context.Context, ref string) (bool, error)
}

type Secret

type Secret struct {
	Provider string `json:"provider"`
}

type SecretMap

type SecretMap map[string]Secret

func (*SecretMap) Scan

func (secrets *SecretMap) Scan(value any) error

func (SecretMap) Value

func (secrets SecretMap) Value() (driver.Value, error)

type Server

type Server struct {
	Type     string         `json:"type"`
	Config   map[string]any `json:"config,omitempty"`
	Secrets  string         `json:"secrets,omitempty"`
	Tools    []string       `json:"tools"`
	Source   string         `json:"source,omitempty"`
	Image    string         `json:"image,omitempty"`
	Endpoint string         `json:"endpoint,omitempty"`

	// CatalogRef is the catalog reference that this server was sourced from.
	CatalogRef string `json:"catalog_ref,omitempty"`

	// Optional snapshot of the server schema
	Snapshot *ServerSnapshot `json:"snapshot,omitempty"`
}

type ServerList

type ServerList []Server

func (*ServerList) Scan

func (servers *ServerList) Scan(value any) error

func (ServerList) Value

func (servers ServerList) Value() (driver.Value, error)

type ServerSnapshot added in v0.26.0

type ServerSnapshot struct {
	// TODO(cody): hacky reference to the same type that we use elsewhere
	Server catalog.Server `json:"server"`
}

func (*ServerSnapshot) Scan added in v0.28.0

func (snapshot *ServerSnapshot) Scan(value any) error

func (*ServerSnapshot) Value added in v0.28.0

func (snapshot *ServerSnapshot) Value() (driver.Value, error)

Used as a column in catalogs

type ToolList added in v0.28.0

type ToolList []string

func (*ToolList) Scan added in v0.28.0

func (tools *ToolList) Scan(value any) error

func (ToolList) Value added in v0.28.0

func (tools ToolList) Value() (driver.Value, error)

type WorkingSet

type WorkingSet struct {
	ID      string     `db:"id"`
	Name    string     `db:"name"`
	Servers ServerList `db:"servers"`
	Secrets SecretMap  `db:"secrets"`
}

type WorkingSetDAO

type WorkingSetDAO interface {
	GetWorkingSet(ctx context.Context, id string) (*WorkingSet, error)
	ListWorkingSets(ctx context.Context) ([]WorkingSet, error)
	CreateWorkingSet(ctx context.Context, workingSet WorkingSet) error
	UpdateWorkingSet(ctx context.Context, workingSet WorkingSet) error
	RemoveWorkingSet(ctx context.Context, id string) error
	SearchWorkingSets(ctx context.Context, query string, workingSetID string) ([]WorkingSet, error)
}

Jump to

Keyboard shortcuts

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