db

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPasswordLength      = 9
	TokenExpirationMinutes = 1440 // 24 hours
	CacheExpirationTime    = 5    // 5 minutes
	CacheCleanupInterval   = 10   // 10 minutes
	DefaultLogLimit        = 10   // Default limit for log pagination
	DefaultLogOffset       = 0    // Default offset for log pagination
	MaxRetries             = 5
	RetryDelay             = 2 * time.Second
	DbRetryDelay           = 5 * time.Second
	DbMaxRetries           = 5
	DbRetryBackoff         = 2 * time.Second
	DefaultLicenseExpiry   = 60
)
View Source
const (
	SelectAllUsersQuery     = "SELECT id, username, password, created_at, role FROM users"
	SelectUserQuery         = "SELECT id, username, password, role FROM users WHERE id = ?"
	InsertUserQuery         = "INSERT INTO users (username, password, created_at, role) VALUES (?, ?, ?, ?)"
	UpdateUserQuery         = "UPDATE users SET username = ?, password = ?, role = ? WHERE id = ?"
	DeleteUserQuery         = "DELETE FROM users WHERE id = ?"
	SelectUserPasswordQuery = "SELECT password, role FROM users WHERE username = ?"
	InsertTokenQuery        = "INSERT INTO token (token_value, username, expires_at, role) VALUES (?, ?, ?, ?)"
	ValidateTokenQuery      = "SELECT username,role FROM token WHERE token_value = ? AND expires_at > NOW()"
	DeleteTokenQuery        = "DELETE FROM token WHERE token_value = ?"
	DeleteExpiredTokenQuery = "DELETE FROM token WHERE expires_at < NOW()"
)

Variables

This section is empty.

Functions

func ConnectWithRetry

func ConnectWithRetry(maxRetries int, retryDelay time.Duration) (*sql.DB, error)

func InitDB

func InitDB() (*sql.DB, error)

func IsDuplicateEntryError

func IsDuplicateEntryError(err error) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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