config

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB = &DBConfig{}

DB is the mysql config instance

View Source
var GRPC = &GRPCConfig{}

GRPC is the grpc config instance

View Source
var HTTP = &HTTPConfig{}

HTTP is the http config instance

View Source
var Main = &MainConfig{}

Main is the log config instance

View Source
var Profiling = &ProfilingConfig{}

Profiling is the profiling config instance

View Source
var Redis = &RedisConfig{Config: &rdb.Config{}}

Redis is the redis config instance

Functions

func Load

func Load(file string) error

Load load all configs

Types

type Config

type Config interface {
	// SectionName return the section name
	SectionName() string

	// Load load the config in the section specified in `SectionName()`
	Load(*ini.Section) error
}

Config defines the config interface

type DBConfig

type DBConfig struct {
	DataSource      string
	MaxIdleConns    int
	MaxOpenConns    int
	ConnMaxLifetime time.Duration
}

DBConfig defines the mysql config

func (*DBConfig) Load

func (conf *DBConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*DBConfig) SectionName

func (conf *DBConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

type GRPCConfig added in v1.2.0

type GRPCConfig struct {
	Addr       string
	LogFile    string
	LogSampler LogSamplerConfig
}

GRPCConfig defines the grpc config

func (*GRPCConfig) Load added in v1.2.0

func (conf *GRPCConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*GRPCConfig) SectionName added in v1.2.0

func (conf *GRPCConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

type HTTPConfig

type HTTPConfig struct {
	Addr           string
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	MaxHeaderBytes int
	MaxBodyBytes   int64
	LogFile        string
	LogSampler     LogSamplerConfig
}

HTTPConfig defines the HTTP config

func (*HTTPConfig) Load

func (conf *HTTPConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*HTTPConfig) SectionName

func (conf *HTTPConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

type LogSamplerConfig added in v1.2.0

type LogSamplerConfig struct {
	Enabled    bool
	Tick       time.Duration
	First      int
	ThereAfter int
}

type MainConfig

type MainConfig struct {
	PIDFile string
	LogDir  string
}

MainConfig defines the Main config

func (*MainConfig) Load

func (conf *MainConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*MainConfig) SectionName

func (conf *MainConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

type ProfilingConfig

type ProfilingConfig struct {
	Enabled bool
	Port    int
}

ProfilingConfig defines the profiling config

func (*ProfilingConfig) Load

func (conf *ProfilingConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*ProfilingConfig) SectionName

func (conf *ProfilingConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

type RedisConfig

type RedisConfig struct {
	*rdb.Config
}

Config defines the redis config

func (*RedisConfig) Load

func (conf *RedisConfig) Load(section *ini.Section) error

Load implements the `Config.Load()` method

func (*RedisConfig) SectionName

func (conf *RedisConfig) SectionName() string

SectionName implements the `Config.SectionName()` method

Jump to

Keyboard shortcuts

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