metadata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArcInstanceNotFound = errors.New("arc instance not found")

ErrArcInstanceNotFound is returned when no arc_instances row matches the lookup.

Functions

func GenerateID

func GenerateID(prefix string) string

GenerateID creates a prefixed random ID (e.g., "org_a1b2c3d4")

Types

type ArcInstance

type ArcInstance struct {
	ID          string
	OrgID       string
	URL         string
	APIKey      string
	Database    string
	Measurement string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

ArcInstance describes the per-org Arc connection. APIKey is plaintext and is only populated by Get* methods (after decryption); Create/Update consume it, encrypt, and discard.

type ArcInstanceStore

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

ArcInstanceStore wraps the arc_instances table with envelope encryption for the API key column.

func NewArcInstanceStore

func NewArcInstanceStore(db *sql.DB, cipher *crypto.Cipher) *ArcInstanceStore

NewArcInstanceStore returns a store using the supplied DB handle and cipher.

func (*ArcInstanceStore) Count

func (s *ArcInstanceStore) Count(ctx context.Context) (int, error)

Count returns the total number of configured arc instances. Used by auto-migration to detect a fresh install.

func (*ArcInstanceStore) Create

func (s *ArcInstanceStore) Create(ctx context.Context, inst *ArcInstance) error

Create inserts a new arc instance, encrypting the API key before write.

func (*ArcInstanceStore) Delete

func (s *ArcInstanceStore) Delete(ctx context.Context, orgID string) error

Delete removes the arc_instances row for an org. Returns ErrArcInstanceNotFound if no row matched.

func (*ArcInstanceStore) GetByOrg

func (s *ArcInstanceStore) GetByOrg(ctx context.Context, orgID string) (*ArcInstance, error)

GetByOrg returns the (decrypted) Arc instance for an org or ErrArcInstanceNotFound if none is configured.

func (*ArcInstanceStore) List

func (s *ArcInstanceStore) List(ctx context.Context) ([]*ArcInstance, error)

List returns every configured instance, with API keys decrypted.

func (*ArcInstanceStore) Update

func (s *ArcInstanceStore) Update(ctx context.Context, inst *ArcInstance) error

Update replaces the URL, API key, database, and measurement for an existing instance keyed by org_id.

type DB

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

DB wraps the SQLite metadata database

func New

func New(dbPath string, logger zerolog.Logger) (*DB, error)

New creates a new metadata DB and initializes the schema

func (*DB) Close

func (mdb *DB) Close() error

Close closes the metadata database

func (*DB) GetDB

func (mdb *DB) GetDB() *sql.DB

GetDB returns the underlying sql.DB for use by other packages

Jump to

Keyboard shortcuts

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