confs

package
v0.0.0-...-f038164 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseConf

type DatabaseConf struct {
	Type         string   `env:"TYPE" yaml:"type,omitempty"`
	Driver       string   `env:"DRIVER" yaml:"driver,omitempty"`
	Database     string   `env:"DATABASE" yaml:"database,omitempty"`
	Username     string   `env:"USERNAME" yaml:"username,omitempty"`
	Password     string   `env:"PASSWORD" yaml:"password,omitempty"`
	Host         string   `env:"HOST" yaml:"host,omitempty"`
	Port         int      `env:"PORT" yaml:"port,omitempty"`
	Schema       string   `env:"SCHEMA" yaml:"schema,omitempty"`
	CreateSchema bool     `env:"CREATE_SCHEMA" yaml:"create_schema,omitempty"`
	DSN          string   `env:"DSN" yaml:"dsn,omitempty"`
	GORM         GORMConf `envPrefix:"GORM_" yaml:"gorm,omitempty"`

	DriverOptions DatabaseDriverOptions `envPrefix:"DRIVER_" yaml:"driver_options,omitempty"`
	Attributes    map[string]string     `envPrefix:"ATTR_" yaml:"attributes,omitempty"` // ConnectionAttributes
}

func (*DatabaseConf) BuildDSN

func (conf *DatabaseConf) BuildDSN() string

type DatabaseDriverOptions

type DatabaseDriverOptions struct {
	MaxIdleConnections int            `env:"MAX_IDLE_CONNS" yaml:"max_idle_connections,omitempty"`
	MaxOpenConnections int            `env:"MAX_OPEN_CONNS" yaml:"max_open_connections,omitempty"`
	ConnMaxIdleTime    time.Duration  `env:"MAX_IDLE_TIME" yaml:"conn_max_idle_time,omitempty"`
	ConnMaxLifetime    *time.Duration `env:"MAX_LIVE_TIME" yaml:"conn_max_lifetime,omitempty"`
}

type DebugConf

type DebugConf struct {
	ListenConf `yaml:",inline"`
	Enabled    bool `env:"ENABLED" envDefault:"true" yaml:"enabled,omitempty"`
}

type DirConf

type DirConf struct {
	Name      string `yaml:"name,omitempty"` // application name
	RootDir   string `env:"ROOT_DIR" yaml:"root_dir,omitempty"`
	DataDir   string `env:"DATA_DIR" yaml:"data_dir,omitempty"`
	CacheDir  string `env:"CACHE_DIR" yaml:"cache_dir,omitempty"`
	ConfigDir string `env:"CONFIG_DIR" yaml:"config_dir,omitempty"`
}

func (*DirConf) InitDirConf

func (conf *DirConf) InitDirConf(name string)

func (*DirConf) SetDirEnv

func (conf *DirConf) SetDirEnv() error

type GORMConf

type GORMConf struct {
	DisableForeignKeyConstraintWhenMigrating bool       `yaml:"disable_foreign_key_constraint_when_migrating,omitempty"`
	Log                                      SQLLogConf `envPrefix:"LOG_" yaml:"log,omitempty"`
}

type GRPCConf

type GRPCConf struct {
	ListenConf `yaml:",inline"`
	Enabled    bool            `env:"ENABLED" envDefault:"true" yaml:"enabled,omitempty"`
	Gateway    GRPCGatewayConf `envPrefix:"GATEWAY_" yaml:"gateway,omitempty"`
}

type GRPCGatewayConf

type GRPCGatewayConf struct {
	ListenConf `yaml:",inline"`
	Enabled    bool   `env:"ENABLED" envDefault:"true" yaml:"enabled,omitempty"`
	Prefix     string `env:"PREFIX" yaml:"prefix,omitempty"`
}

type HTTPConf

type HTTPConf struct {
	ListenConf `yaml:",inline"`
}

type ListenConf

type ListenConf struct {
	Addr string `env:"ADDR" yaml:"addr,omitempty"`
	Port int    `env:"PORT" yaml:"port,omitempty"`
}

func (ListenConf) GetAddr

func (c ListenConf) GetAddr() string

func (ListenConf) Listen

func (c ListenConf) Listen() (net.Listener, error)

func (ListenConf) Serve

func (c ListenConf) Serve(ss ServeService) error

type LogConf

type LogConf struct {
	Level string `env:"LEVEL" envDefault:"info" yaml:"level,omitempty"`
}

type RedisConf

type RedisConf struct {
	DSN          string            `env:"DSN" yaml:"dsn,omitempty"`
	Address      string            `env:"ADDRESS" yaml:"address,omitempty"`
	Username     string            `env:"USERNAME" yaml:"username,omitempty"`
	Password     string            `env:"PASSWORD" yaml:"password,omitempty"`
	Database     int               `env:"DATABASE" yaml:"database,omitempty"`
	DialTimeout  time.Duration     `env:"DIAL_TIMEOUT" yaml:"dial_timeout,omitempty"`
	ReadTimeout  time.Duration     `env:"READ_TIMEOUT" yaml:"read_timeout,omitempty"`
	WriteTimeout time.Duration     `env:"WRITE_TIMEOUT" yaml:"write_timeout,omitempty"`
	Attributes   map[string]string `envPrefix:"ATTR_" yaml:"attributes,omitempty"`
}

func (*RedisConf) ApplyDNS

func (rc *RedisConf) ApplyDNS()

type SQLLogConf

type SQLLogConf struct {
	SlowThreshold  time.Duration `env:"SLOW_THRESHOLD" yaml:"slow_threshold,omitempty"`
	IgnoreNotFound bool          `env:"IGNORE_NOT_FOUND" yaml:"ignore_not_found,omitempty"`
	Debug          bool          `env:"DEBUG" yaml:"debug,omitempty"`
}

type ServeService

type ServeService interface {
	Serve(l net.Listener) error
}

Jump to

Keyboard shortcuts

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