Documentation
¶
Index ¶
- func CloseAllConnections(_ context.Context)
- func ConfigureConnectionPool(db *gorm.DB) error
- func GetDefaultPort(dbType engine.DatabaseType) (string, bool)
- func GetGormLogConfig() logger.LogLevel
- func RegisterDatabasePort(dbType engine.DatabaseType, port string)
- func RegisterEEPlugins(e *engine.Engine)
- func RemoveConnection(config *engine.PluginConfig)
- func WithConnection[T any](config *engine.PluginConfig, DB DBCreationFunc, operation DBOperation[T]) (T, error)
- type AndCondition
- type AtomicCondition
- type DBCreationFunc
- type DBOperation
- type OrCondition
- type SearchCondition
- type Sort
- type SortDirection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseAllConnections ¶
CloseAllConnections closes all cached connections (call on shutdown).
func ConfigureConnectionPool ¶
ConfigureConnectionPool sets recommended connection pool settings for database connections. This should be called after opening a GORM connection to ensure proper pool management. Settings are tuned for long-running server applications with connection caching.
func GetDefaultPort ¶
func GetDefaultPort(dbType engine.DatabaseType) (string, bool)
GetDefaultPort returns the default port for a database type
func GetGormLogConfig ¶
GetGormLogConfig returns the GORM logger level based on the environment log level setting.
func RegisterDatabasePort ¶
func RegisterDatabasePort(dbType engine.DatabaseType, port string)
RegisterDatabasePort allows external packages to register additional database ports
func RegisterEEPlugins ¶
RegisterEEPlugins registers enterprise edition plugins if available
func RemoveConnection ¶
func RemoveConnection(config *engine.PluginConfig)
RemoveConnection removes a specific connection from cache and closes it (call on logout).
func WithConnection ¶
func WithConnection[T any](config *engine.PluginConfig, DB DBCreationFunc, operation DBOperation[T]) (T, error)
WithConnection manages the database connection lifecycle for an operation. Connections are cached and reused across operations to prevent connection exhaustion. The underlying sql.DB handles connection pooling internally.
Types ¶
type AndCondition ¶
type AndCondition struct {
Conditions []SearchCondition
}
AndCondition represents multiple conditions joined with AND.
type AtomicCondition ¶
AtomicCondition represents a single comparison condition (e.g., column = value).
type DBCreationFunc ¶
type DBCreationFunc func(pluginConfig *engine.PluginConfig) (*gorm.DB, error)
DBCreationFunc is a function that creates a new GORM database connection.
type DBOperation ¶
DBOperation is a function that performs database operations with a GORM connection.
type OrCondition ¶
type OrCondition struct {
Conditions []SearchCondition
}
OrCondition represents multiple conditions joined with OR.
type SearchCondition ¶
type SearchCondition struct {
And *AndCondition
Or *OrCondition
Atomic *AtomicCondition
}
SearchCondition represents a WHERE clause condition that can be atomic, AND, or OR.
type Sort ¶
type Sort struct {
Column string
Direction SortDirection
}
Sort represents a column sort condition with direction.
type SortDirection ¶
type SortDirection int
SortDirection indicates ascending or descending sort order.
const ( Up SortDirection = iota // ASC Down // DESC )