database

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendKeepalivePings added in v2.2.0

func SendKeepalivePings(ctx context.Context, db *sql.DB, interval time.Duration) func() error

SendKeepalivePings will periodically send a lightweight query to a database in order to keep active, idle connections from being killed by an external source.

Types

type MSSqlSettings

type MSSqlSettings struct {
	Host     string
	User     string
	Password string
	Name     *string
	AppName  string
}

MSSqlSettings is the settings for a ms sql database

func (*MSSqlSettings) GetDB

func (ds *MSSqlSettings) GetDB() (*sql.DB, error)

GetDB will return a database instance from the settings

func (*MSSqlSettings) WaitForDatabaseToBeOnline

func (ds *MSSqlSettings) WaitForDatabaseToBeOnline(secondsToWait int) error

WaitForDatabaseToBeOnline will wait for the database server to be online for the given seconds.

type PostgresDatabaseSettings

type PostgresDatabaseSettings struct {
	Host     string
	Port     int
	User     string
	Password string
	Name     string
}

PostgresDatabaseSettings are the settings for a postgres database

func (*PostgresDatabaseSettings) EnsureDatabaseExistsAndGetConnection

func (ds *PostgresDatabaseSettings) EnsureDatabaseExistsAndGetConnection() (*sql.DB, error)

EnsureDatabaseExistsAndGetConnection will create the database if it doesn't exist and return a connection.

func (*PostgresDatabaseSettings) MigrateUpWithStatik

func (ds *PostgresDatabaseSettings) MigrateUpWithStatik(subdirectory string) error

MigrateUpWithStatik migrates the database using statik

func (*PostgresDatabaseSettings) WaitForDatabaseToBeOnline

func (ds *PostgresDatabaseSettings) WaitForDatabaseToBeOnline(secondsToWait int) error

WaitForDatabaseToBeOnline will wait for the database server to be online for the given seconds.

Jump to

Keyboard shortcuts

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