gormkitteh

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

TODO: Make public?

Index

Constants

View Source
const RequireExplicitDSNType = "require"

Variables

View Source
var (
	ErrInvalidDSN  = errors.New("invalid DSN")
	ErrUnknownType = errors.New("unknown DSN type")
)

Functions

func Open

func Open(cfg *Config, f func(*gorm.Config)) (*gorm.DB, error)

Open a DB according to given configuration. Open calls cfg.Explicit() is called before evaluating it.

func OpenZ

func OpenZ(z *zap.Logger, cfg *Config, f func(*gorm.Config)) (*gorm.DB, error)

Types

type Config

type Config struct {
	// If `Type` is empty, `DSN` must be in the form of "type:actual_dsn".
	// If both `Type` and `DSN` are empty, `Type` will be considered "sqlite"
	// with an empty DSN, which will make sqlite use a temporary database
	// (see https://www.sqlite.org/inmemorydb.html).
	// If `Type` is "require" (RequireExplicitDSNType), `DSN` must be specified.
	Type  string `koanf:"type"`
	DSN   string `koanf:"dsn"`
	Debug bool   `koanf:"debug"`

	SlowQueryThreshold time.Duration `koanf:"slow_query_threshold"`

	// If true, DB migrations will run automatically.
	// If false, the server will fail to start if a migration is required,
	// and the user has to run 'ak server migrate' explicitly.
	AutoMigrate bool `koanf:"auto_migrate"`

	Ownership string `koanf:"ownership"`

	MaxOpenConns int `koanf:"max_open_conns"`
	MaxIdleConns int `koanf:"max_idle_conns"`
}

func (Config) Explicit

func (c Config) Explicit() (*Config, error)

Jump to

Keyboard shortcuts

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