{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package db_session\n\n## Types\n\n```go\ntype Default struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewProdFactory(config *config.DatabaseConfig) *Default\n```\n\n```go\nfunc (f *Default) CheckConnection() error\n```\n\n```go\nfunc (f *Default) Close() error\n```\nClose will close the connection to the database. THIS MUST \\*\\*NOT\\*\\* BE CALLED UNTIL THE SERVER/PROCESS IS EXITING!! This should only ever be called once for the entire duration of the application and only at the end.\n\n```go\nfunc (f *Default) DirectDB() *sql.DB\n```\n\n```go\nfunc (f *Default) GetAdvisoryLockTimeout() int\n```\n\n```go\nfunc (f *Default) Init(config *config.DatabaseConfig)\n```\nInit will initialize a singleton connection as needed and return the same instance. Go includes database connection pooling in the platform. Gorm uses the same and provides a method to clone a connection via New(), which is safe for use by concurrent Goroutines.\n\n```go\nfunc (f *Default) New(ctx context.Context) *gorm.DB\n```\nNew returns a GORM DB session. If a transaction exists in context, returns that transaction so DAO operations participate. Otherwise returns a non-transactional session.\n\n```go\nfunc (f *Default) NewListener(ctx context.Context, channel string, callback func(id string))\n```\n\n```go\nfunc (f *Default) ReconfigureLogger(level gormlogger.LogLevel)\n```\nReconfigureLogger changes the GORM logger level at runtime\n\n```go\nfunc (f *Default) ResetDB()\n```\n\n```go\ntype LoggerReconfigurable interface {\n\tReconfigureLogger(level logger.LogLevel)\n}\n```\nLoggerReconfigurable allows runtime reconfiguration of the database logger\n\n```go\ntype Test struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTestFactory(config *config.DatabaseConfig) *Test\n```\n\n```go\nfunc (f *Test) CheckConnection() error\n```\nCheckConnection checks to ensure a connection is present\n\n```go\nfunc (f *Test) Close() error\n```\n\n```go\nfunc (f *Test) DirectDB() *sql.DB\n```\n\n```go\nfunc (f *Test) GetAdvisoryLockTimeout() int\n```\n\n```go\nfunc (f *Test) Init(config *config.DatabaseConfig)\n```\nInit will: - initialize a template1 DB with migrations - rebuild AMS DB from template1 - return a new connection factory Go includes database connection pooling in the platform. Gorm uses the same and provides a method to clone a connection via New(), which is safe for use by concurrent Goroutines.\n\n```go\nfunc (f *Test) New(ctx context.Context) *gorm.DB\n```\n\n```go\nfunc (f *Test) NewListener(ctx context.Context, channel string, callback func(id string))\n```\n\n```go\nfunc (f *Test) ReconfigureLogger(level gormlogger.LogLevel)\n```\nReconfigureLogger changes the GORM logger level at runtime\n\n```go\nfunc (f *Test) ResetDB()\n```\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/db/db_session","name":"db_session","synopsis":"","isRedistributable":true}
