types

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TRUE            = true
	FALSE           = false
	DefaultDbDriver = "mysql"

	ErrNoBackend = errors.New("no backend configured")
)

Functions

This section is empty.

Types

type BackendConfig

type BackendConfig struct {
	// optional name of driver, if omitted, then "mysql"  is assumed
	Driver *string `yaml:"driver,omitempty"`
	DSN    string  `yaml:"dsn"`
	Create *bool   `yaml:"create,omitempty"`
	Read   *bool   `yaml:"read,omitempty"`
	Update *bool   `yaml:"update,omitempty"`
	Delete *bool   `yaml:"delete,omitempty"`
	// Optional mapping from entity (table) name to ID column.
	// If not specified, then "id" is assumed
	IdMap *map[string]string `yaml:"id_map,omitempty"`

	MaxOpenConnections *int           `yaml:"max_open_connections,omitempty"`
	MaxIdleConnections *int           `yaml:"max_idle_connections,omitempty"`
	ConnMaxLifetime    *time.Duration `yaml:"conn_max_lifetime,omitempty"`
	ConnMaxIdleTime    *time.Duration `yaml:"conn_max_idle_time,omitempty"`
	// contains filtered or unexported fields
}

func (*BackendConfig) Close

func (be *BackendConfig) Close() error

func (*BackendConfig) DB

func (be *BackendConfig) DB() *sql.DB

func (*BackendConfig) IdColumn

func (be *BackendConfig) IdColumn(ent string) string

IdColumn gets ID column for given entity, see IdMap

func (*BackendConfig) Open

func (be *BackendConfig) Open() error

type Backends

type Backends map[string]*BackendConfig

type Config

type Config struct {
	Server        ccfg.ServerConfig `yaml:"server"`
	Backends      Backends          `yaml:"backends"`
	LoggingConfig *LoggingConfig    `yaml:"logging,omitempty"`
}

func (*Config) CheckAndNormalize

func (c *Config) CheckAndNormalize() error

CheckAndNormalize sets any missing optional values and ensures all values are semantically correct.

type LoggingConfig

type LoggingConfig struct {
	Level  *string `yaml:"level,omitempty"`
	Format *string `yaml:"format,omitempty"`
}

Jump to

Keyboard shortcuts

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