stratus

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 12 Imported by: 0

README

stratus

Documentation

Overview

Package stratus is a lazy implementation of a singleton pattern for a single database. The current implementation does not support multiple database. Will cross that bridge when needed. For now, this is sufficient. It is assumed that the database will be initialized from within `cmd/main.go` by calling `stratus.Connect`, and that the `GetInstance()` function will be used to load the reference into other services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(driver, dsn string, opts ...func(*sql.DB) error) (err error)

Connect opens the connection to the database through GORM. Will panic if a connection fails, will return an error if issues arise when trying to set DB options.

func GetInstance

func GetInstance() *gorm.DB

GetInstance is a lazy devs attempt to provide a singleton to the primary db instance. GetInstance will panic if the database has not been initialized by calling `db.Connect`.

func WithMaxConnections

func WithMaxConnections(max int) func(*sql.DB) error

WithMaxConnections allows for the setting of `MaxOpenConns` for the underlying `*sql.DB` instance during database initialization.

func WithMaxIdleConnections

func WithMaxIdleConnections(max int) func(*sql.DB) error

WithMaxIdleConnections allows for the setting of `MaxIdleConns` for the underlying `*sql.DB` instance during database initialization.

Types

This section is empty.

Jump to

Keyboard shortcuts

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