config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 5 Imported by: 0

README

config

GoDoc

This package provides a config interface and a default config struct.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg Config) error

LoadConfig loads configs

Types

type ClientConfig added in v0.2.0

type ClientConfig struct {
	Scheme string `yaml:"scheme"`
	Domain string `yaml:"domain"`
	Port   uint16 `yaml:"port"`
}

ClientConfig is common client config

func (ClientConfig) Host added in v0.2.0

func (cc ClientConfig) Host() string

Host - return the host

type Config

type Config interface {
	Load() error
}

Config is the config interface

type DatabaseConfig

type DatabaseConfig struct {
	DSN             string
	Host            string `yaml:"host"`
	Port            int    `yaml:"port"`
	Username        string `yaml:"username"`
	Password        string `yaml:"password"`
	DB              string `yaml:"db"`
	MaxIdleConns    int    `yaml:"max_idle_conns"`
	MaxOpenConns    int    `yaml:"max_open_conns"`
	ConnMaxLifetime int    `yaml:"conn_max_life_time"`
}

DatabaseConfig is common database configs

func (*DatabaseConfig) BuildDSN

func (dc *DatabaseConfig) BuildDSN()

BuildDSN builds data source name

type MainConfig

type MainConfig struct {
	Databases map[string]*DatabaseConfig `yaml:"databases"`
	Redis     RedisConfig                `yaml:"redis"`
	Server    ServerConfig               `yaml:"server"`
	Clients   map[string]*ClientConfig   `yaml:"clients"`
}

MainConfig implements Config interface

func (*MainConfig) BuildDSN

func (cfg *MainConfig) BuildDSN()

BuildDSN builds data source name for each database

func (*MainConfig) Load

func (cfg *MainConfig) Load() error

Load loads configs and build dsn

type RedisConfig

type RedisConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	DB       int    `yaml:"db"`
	Sentinel bool   `yaml:"sentinel"`
}

RedisConfig is common Redis configs

func (*RedisConfig) Addr

func (rc *RedisConfig) Addr() string

Addr returns redis address

type ServerConfig

type ServerConfig struct {
	Scheme   string            `yaml:"scheme"`
	Domain   string            `yaml:"domain"`
	HTTPPort uint16            `yaml:"http_port"`
	GRPCPort uint16            `yaml:"grpc_port"`
	Dir      map[string]string `yaml:"dir"`
}

ServerConfig is common server configs

func (ServerConfig) GRPCHost

func (sc ServerConfig) GRPCHost() string

GRPCHost - return the grpc host

func (ServerConfig) HTTPHost

func (sc ServerConfig) HTTPHost() string

HTTPHost - return the http host

type TracingConfig

type TracingConfig struct {
	Service        string `yaml:"service"`
	SamplingServer string `yaml:"sampling_server"`
	LocalAgent     string `yaml:"local_agent"`
	Debug          bool   `yaml:"debug"`
}

TracingConfig is common open tracing configs

Jump to

Keyboard shortcuts

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