types

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 5 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")
	ErrTlsKeyPathMissing  = errors.New("server.http_tls_config.tls_key_path is required")
	ErrTlsCertPathMissing = errors.New("server.http_tls_config.tls_cert_path is required")
)

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        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 CorsConfig

type CorsConfig struct {
	AllowedOrigins []string `yaml:"allowed_origins"`
	MaxAge         int      `yaml:"max_age"`
}

type LoggingConfig

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

type ServerConfig

type ServerConfig struct {
	HTTPListenAddress string      `yaml:"http_listen_address"`
	HTTPTLSConfig     *TLSConfig  `yaml:"http_tls_config"`
	CorsConfig        *CorsConfig `yaml:"cors"`
}

type TLSConfig

type TLSConfig struct {
	TLSCertPath string `yaml:"cert_file"`
	TLSKeyPath  string `yaml:"key_file"`
	ClientAuth  string `yaml:"client_auth_type"`
	ClientCAs   string `yaml:"client_ca_file"`
}

Jump to

Keyboard shortcuts

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