config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Postgres = "postgres"
	Sqlite   = "sqlite"
)

Variables

This section is empty.

Functions

func OpenDbConnection

func OpenDbConnection(ctx context.Context, config DbConnectionConfigProvider) (*gorm.DB, error)

Opens a connection to the database specified in the config. You must call CloseDbConnection at the end of your session!

Types

type BaseConfig

type BaseConfig struct {
	LogLevel                                 logger.LogLevel `json:"log_level"`
	DisableForeignKeyConstraintWhenMigrating bool
}

type DbConnectionConfigProvider

type DbConnectionConfigProvider interface {
	// Returns database dialector
	GetDialector() gorm.Dialector

	GetDBConfig() database.DbConfig

	GetDSN() string
}

Generic interface for providing a config necessary to open a database connection.

func NewPostgresConfigProvider

func NewPostgresConfigProvider(config database.DbConfig, scope promutils.Scope) DbConnectionConfigProvider

TODO : Make the Config provider itself env based

type PostgresConfigProvider

type PostgresConfigProvider struct {
	// contains filtered or unexported fields
}

PostgreSQL implementation for DbConnectionConfigProvider.

func (*PostgresConfigProvider) GetDBConfig

func (p *PostgresConfigProvider) GetDBConfig() database.DbConfig

func (*PostgresConfigProvider) GetDSN

func (p *PostgresConfigProvider) GetDSN() string

func (*PostgresConfigProvider) GetDialector

func (p *PostgresConfigProvider) GetDialector() gorm.Dialector

Jump to

Keyboard shortcuts

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