db

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBPath         string
	MaxOpenConns   int
	MaxIdleConns   int
	AutoInitialize bool // Automatically initialize schema if DB doesn't exist
}

Config holds database configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default database configuration

type Service

type Service struct {
	DB     *sql.DB
	DBPath string
}

Service represents the database service with connection management

func New

func New(config *Config) (*Service, error)

New creates a new database service instance

func NewService

func NewService() (*Service, error)

NewService creates a new database service with default configuration

func (*Service) Close

func (s *Service) Close() error

Close closes the database connection

func (*Service) EntityExists

func (s *Service) EntityExists(entityID string) (bool, error)

EntityExists checks if an entity exists in the database

func (*Service) GetDB

func (s *Service) GetDB() *sql.DB

GetDB returns the underlying database connection

func (*Service) GetSchemaVersion

func (s *Service) GetSchemaVersion() (string, error)

GetSchemaVersion returns the current schema version This is a placeholder for future versioning support

func (*Service) GetStats

func (s *Service) GetStats() sql.DBStats

GetStats returns database connection statistics

func (*Service) Health

func (s *Service) Health() error

Health checks the database connection health

func (*Service) HealthCheck

func (s *Service) HealthCheck() error

HealthCheck returns the health status of the database service (implements Service interface)

func (*Service) InitializeSchema

func (s *Service) InitializeSchema() error

InitializeSchema loads and executes the schema.sql file

func (*Service) MigrateSchema

func (s *Service) MigrateSchema() error

MigrateSchema applies any pending schema migrations This is a placeholder for future migration support

func (*Service) Name

func (s *Service) Name() string

Name returns the service name (implements Service interface)

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start initializes the database service (implements Service interface)

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop gracefully shuts down the database service (implements Service interface)

func (*Service) Transaction

func (s *Service) Transaction(fn func(*sql.Tx) error) error

Transaction executes a function within a database transaction

func (*Service) VerifySchema

func (s *Service) VerifySchema() error

VerifySchema checks if the database schema is properly initialized

Jump to

Keyboard shortcuts

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