Versions in this module Expand all Collapse all v1 v1.0.0 Feb 3, 2026 Changes in this version + func GetSupportedDrivers() []string + func IsRemoteDriver(driver string) bool + func ValidateRemoteConnection(cfg *RemoteDBConfig) error + type APIToken struct + Active bool + CreatedAt time.Time + Description string + ExpiresAt *time.Time + ID int64 + LastUsed *time.Time + Name string + Permissions []string + RateLimit int + Token string + type AdminSession struct + CreatedAt time.Time + ExpiresAt time.Time + ID int64 + IPAddress string + Token string + UserAgent string + UserID int64 + type AdminUser struct + Active bool + CreatedAt time.Time + Email string + ID int64 + LastLogin *time.Time + PasswordHash string + Role string + UpdatedAt time.Time + Username string + type AuditLogEntry struct + Action string + Details string + ID int64 + IPAddress string + Resource string + Timestamp time.Time + UserAgent string + UserID *int64 + type BlockedIP struct + BlockedBy string + CreatedAt time.Time + ExpiresAt *time.Time + ID int64 + IPAddress string + Reason string + type ClusterManager struct + func NewClusterManager(dm *DatabaseManager) (*ClusterManager, error) + func (cm *ClusterManager) GenerateJoinToken(ctx context.Context) (string, error) + func (cm *ClusterManager) GetNode(ctx context.Context, nodeID string) (*ClusterNode, error) + func (cm *ClusterManager) GetNodes(ctx context.Context) ([]*ClusterNode, error) + func (cm *ClusterManager) Hostname() string + func (cm *ClusterManager) IsClusterMode() bool + func (cm *ClusterManager) IsPrimary() bool + func (cm *ClusterManager) LeaveCluster(ctx context.Context) error + func (cm *ClusterManager) Mode() ClusterMode + func (cm *ClusterManager) NodeID() string + func (cm *ClusterManager) Start(ctx context.Context) error + func (cm *ClusterManager) Stop() + type ClusterMode string + const ClusterModeCluster + const ClusterModeStandalone + type ClusterNode struct + Address string + Hostname string + ID string + IsPrimary bool + JoinedAt time.Time + LastSeen time.Time + Metadata map[string]string + Port int + Status NodeStatus + Version string + type Config struct + DSN string + DataDir string + Driver string + Lifetime int + MaxIdle int + MaxOpen int + func DefaultConfig() *Config + type DB struct + func New(cfg *Config) (*DB, error) + func (db *DB) Begin(ctx context.Context) (*sql.Tx, error) + func (db *DB) Close() error + func (db *DB) Driver() string + func (db *DB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + func (db *DB) IsReady() bool + func (db *DB) IsRemote() bool + func (db *DB) Ping(ctx context.Context) error + func (db *DB) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + func (db *DB) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row + func (db *DB) SQL() *sql.DB + type DatabaseBackendConfig struct + DSN string + Driver string + Lifetime int + MaxIdle int + MaxOpen int + Path string + type DatabaseManager struct + func NewDatabaseManager(cfg *Config) (*DatabaseManager, error) + func (dm *DatabaseManager) Close() error + func (dm *DatabaseManager) IsClusterMode() bool + func (dm *DatabaseManager) IsReady() bool + func (dm *DatabaseManager) Ping(ctx context.Context) error + func (dm *DatabaseManager) ServerDB() *DB + func (dm *DatabaseManager) UsersDB() *DB + type DatabaseMigrator struct + func NewDatabaseMigrator(dm *DatabaseManager) *DatabaseMigrator + func (dbm *DatabaseMigrator) GetServerMigrator() *Migrator + func (dbm *DatabaseMigrator) GetUsersMigrator() *Migrator + func (dbm *DatabaseMigrator) MigrateAll(ctx context.Context) error + type EngineStats struct + AvgResponseTime float64 + Date time.Time + Engine string + ErrorCount int + ID int64 + QueryCount int + ResultCount int + type Migration struct + Description string + Down string + Up string + Version int + type MigrationManager struct + func NewMigrationManager(sourceDB *DB, targetDB *RemoteDB, dataDir string) *MigrationManager + func (mm *MigrationManager) BackupBeforeMigration(dbPath string) (string, error) + func (mm *MigrationManager) MigrateToRemote(ctx context.Context, progress chan<- MigrationProgress) error + type MigrationProgress struct + Error string + MigratedRows int64 + Phase string + StartTime time.Time + Table string + TotalRows int64 + type Migrator struct + func NewMigrator(db *DB) *Migrator + func (m *Migrator) GetMigrations() []Migration + func (m *Migrator) GetVersion(ctx context.Context) (int, error) + func (m *Migrator) Migrate(ctx context.Context) error + func (m *Migrator) Register(migration Migration) + func (m *Migrator) Rollback(ctx context.Context) error + type MixedDB struct + func (mdb *MixedDB) Begin(ctx context.Context) (*sql.Tx, error) + func (mdb *MixedDB) Close() error + func (mdb *MixedDB) Driver() string + func (mdb *MixedDB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + func (mdb *MixedDB) GetPlaceholder(index int) string + func (mdb *MixedDB) IsLocal() bool + func (mdb *MixedDB) IsReady() bool + func (mdb *MixedDB) IsRemote() bool + func (mdb *MixedDB) Ping(ctx context.Context) error + func (mdb *MixedDB) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + func (mdb *MixedDB) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row + func (mdb *MixedDB) SupportsReturning() bool + func (mdb *MixedDB) SupportsUpsert() bool + type MixedModeConfig struct + ServerDB DatabaseBackendConfig + UsersDB DatabaseBackendConfig + func DefaultMixedModeConfig(dataDir string) *MixedModeConfig + type MixedModeManager struct + func NewMixedModeManager(cfg *MixedModeConfig) (*MixedModeManager, error) + func (mm *MixedModeManager) Close() error + func (mm *MixedModeManager) GetMode() string + func (mm *MixedModeManager) GetStatus() map[string]interface{} + func (mm *MixedModeManager) IsMixedMode() bool + func (mm *MixedModeManager) IsReady() bool + func (mm *MixedModeManager) ServerDB() *MixedDB + func (mm *MixedModeManager) UsersDB() *MixedDB + type NodeStatus string + const NodeStatusJoining + const NodeStatusLeaving + const NodeStatusOffline + const NodeStatusOnline + type RemoteDB struct + func NewRemoteDB(cfg *RemoteDBConfig) (*RemoteDB, error) + func (rdb *RemoteDB) Close() error + func (rdb *RemoteDB) DB() *sql.DB + func (rdb *RemoteDB) IsReady() bool + type RemoteDBConfig struct + Database string + Driver string + Host string + Options string + Password string + Port int + SSLMode string + Username string + func DefaultRemoteDBConfig() *RemoteDBConfig + func (r *RemoteDBConfig) BuildDSN() string + type Repository struct + func NewRepository(db *DB) *Repository + func (r *Repository) BlockIP(ctx context.Context, ip *BlockedIP) error + func (r *Repository) CleanupOldAuditLogs(ctx context.Context, olderThanDays int) (int64, error) + func (r *Repository) CreateAPIToken(ctx context.Context, token *APIToken) error + func (r *Repository) CreateAdminSession(ctx context.Context, session *AdminSession) error + func (r *Repository) CreateAdminUser(ctx context.Context, user *AdminUser) error + func (r *Repository) DeleteAPIToken(ctx context.Context, tokenID int64) error + func (r *Repository) DeleteAdminSession(ctx context.Context, token string) error + func (r *Repository) DeleteExpiredSessions(ctx context.Context) (int64, error) + func (r *Repository) GetAPITokenByToken(ctx context.Context, token string) (*APIToken, error) + func (r *Repository) GetAdminSessionByToken(ctx context.Context, token string) (*AdminSession, error) + func (r *Repository) GetAdminUserByID(ctx context.Context, id int64) (*AdminUser, error) + func (r *Repository) GetAdminUserByUsername(ctx context.Context, username string) (*AdminUser, error) + func (r *Repository) GetAuditLog(ctx context.Context, limit, offset int) ([]*AuditLogEntry, error) + func (r *Repository) GetSearchStats(ctx context.Context, startDate, endDate time.Time) ([]*SearchStats, error) + func (r *Repository) IsIPBlocked(ctx context.Context, ipAddress string) (bool, error) + func (r *Repository) ListAPITokens(ctx context.Context) ([]*APIToken, error) + func (r *Repository) ListBlockedIPs(ctx context.Context) ([]*BlockedIP, error) + func (r *Repository) RecordAudit(ctx context.Context, entry *AuditLogEntry) error + func (r *Repository) RecordSearchStats(ctx context.Context, queryCount, resultCount int, responseTime float64, ...) error + func (r *Repository) UnblockIP(ctx context.Context, ipAddress string) error + func (r *Repository) UpdateAPITokenLastUsed(ctx context.Context, tokenID int64) error + func (r *Repository) UpdateAdminUserLastLogin(ctx context.Context, userID int64) error + type SearchStats struct + AvgResponseTime float64 + Categories []string + Date time.Time + EnginesUsed []string + Hour int + ID int64 + QueryCount int + ResultCount int