Documentation
¶
Index ¶
- func ClearTableWithDependencies(plugin engine.PluginFunctions, config *engine.PluginConfig, ...) error
- func CloseAllConnections(_ context.Context)
- func ConfigureConnectionPool(db *gorm.DB) error
- func FindChildTables(graph []engine.GraphUnit, targetTable string) []string
- func GetCachedSSLStatus(config *engine.PluginConfig) *engine.SSLStatus
- func GetGormLogConfig() logger.LogLevel
- func NullifyFKColumn(plugin engine.PluginFunctions, config *engine.PluginConfig, ...) error
- func RemoveConnection(config *engine.PluginConfig)
- func SetCachedSSLStatus(config *engine.PluginConfig, status *engine.SSLStatus)
- func WithConnection[T any](config *engine.PluginConfig, DB DBCreationFunc, operation DBOperation[T]) (T, error)
- type AtomicCondition
- type DBCreationFunc
- type DBOperation
- type Sort
- type SortDirection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearTableWithDependencies ¶
func ClearTableWithDependencies( plugin engine.PluginFunctions, config *engine.PluginConfig, schema, table string, graph []engine.GraphUnit, ) error
ClearTableWithDependencies clears a table and all tables that reference it (children first). This ensures FK constraints are respected by deleting in the correct order. Circular FK references (e.g., employees <-> departments) are handled by NULLing out the FK column that forms the cycle before any rows are deleted.
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 FindChildTables ¶
FindChildTables returns all tables that have FK references to the given table. The graph structure stores parent -> children relationships, so we look at the target table's Relations to find its children (tables that reference it).
func GetCachedSSLStatus ¶
func GetCachedSSLStatus(config *engine.PluginConfig) *engine.SSLStatus
GetCachedSSLStatus retrieves the SSL status from the connection cache. Returns nil if not cached or connection doesn't exist.
func GetGormLogConfig ¶
GetGormLogConfig returns the GORM logger level based on the environment log level setting.
func NullifyFKColumn ¶
func NullifyFKColumn( plugin engine.PluginFunctions, config *engine.PluginConfig, schema, childTable, parentTable string, graph []engine.GraphUnit, ) error
NullifyFKColumn sets the FK column in childTable that references parentTable to NULL. Used to break circular FK constraints before deleting rows.
func RemoveConnection ¶
func RemoveConnection(config *engine.PluginConfig)
RemoveConnection removes a specific connection from cache and closes it (call on logout).
func SetCachedSSLStatus ¶
func SetCachedSSLStatus(config *engine.PluginConfig, status *engine.SSLStatus)
SetCachedSSLStatus stores SSL status in the connection cache.
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. If config.Transaction is set (as a *gorm.DB), it will be used instead of creating a new connection. Multi-statement connections bypass the cache and are closed immediately after use.
Types ¶
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 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 )