types

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 8 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

func NewErrorWithStatus added in v1.0.7

func NewErrorWithStatus(msg string, status int) error

func WrapError added in v1.0.7

func WrapError(msg string, err error) error

func WrapErrorWithStatus added in v1.0.7

func WrapErrorWithStatus(msg string, err error, status int) error

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"`
	// Named queries that could be executed with optional parameters
	Queries map[string]string `yaml:"queries"`
	// DDL queries to be executed at start. Be careful here.
	InitDDLs []string `yaml:"init_ddls,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(ctx context.Context) 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 ErrorWithStatus added in v1.0.7

type ErrorWithStatus struct {
	Status  int
	Msg     string
	Wrapped error
}

func (*ErrorWithStatus) Error added in v1.0.7

func (h *ErrorWithStatus) Error() string

func (*ErrorWithStatus) Unwrap added in v1.0.7

func (h *ErrorWithStatus) Unwrap() error

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