Documentation ¶
Overview ¶
config package from micro-strter-kit import myConfig "github.com/seidu626/audiobook/shared/config" to `main.go` and all test files. add myConfig.InitConfig(configDir, configFile), config.Scan(&cfg) in service.Init()
Index ¶
- Constants
- Variables
- func GetBuildInfo() string
- func InitConfig(configDir, configFile string)
- func LoadExtraConfig(configDir, configFile string)
- func PrintBuildInfo()
- type DatabaseConfiguration
- type DatabaseDialect
- type EmailConfiguration
- type Environment
- type Feature
- type LogConfiguration
- type Service
- type ServiceConfiguration
Constants ¶
const ( // DefaultConfigDir if no ConfigDir supplied DefaultConfigDir = "/config" // DefaultConfigFile if no ConfigFile supplied DefaultConfigFile = "config.yaml" )
Variables ¶
var ( // IsProduction will have CurrentMode of the application IsProduction bool // Version is populated by govvv in compile-time. Version = "untouched" // BuildDate is populated by govvv. BuildDate string // GitCommit is populated by govvv. GitCommit string // GitBranch is populated by govvv. GitBranch string // GitState is populated by govvv. GitState string // GitSummary is populated by govvv. GitSummary string )
Functions ¶
func InitConfig ¶
func InitConfig(configDir, configFile string)
InitConfig loads the configuration from file then from environment variables and then from cli flags
func LoadExtraConfig ¶
func LoadExtraConfig(configDir, configFile string)
LoadExtraConfig loads the extra configuration from file
Types ¶
type DatabaseConfiguration ¶
type DatabaseConfiguration struct { Dialect DatabaseDialect `json:"dialect" default:"postgres"` Host string `json:"host"` Port int `json:"port"` Username string `json:"username"` Password string `json:"password"` Database string `json:"database"` Charset string `json:"charset" default:"utf8"` UTC bool `default:"true"` Logging bool `default:"false"` Singularize bool `default:"false"` MaxOpenConns int `json:"maxOpenConns" default:"1"` MaxIdleConns int `json:"maxIdleConns" default:"1"` ConnMaxLifetime time.Duration `json:"connMaxLifetime" default:"1hr"` Params map[string]interface{} }
DatabaseConfiguration holds db config
func (*DatabaseConfiguration) URL ¶
func (d *DatabaseConfiguration) URL() (url string, err error)
URL returns a connection string for the database.
type DatabaseDialect ¶
type DatabaseDialect string
DatabaseDialect represents a database dialect constant.
const ( // PostgreSQLDialect is the dialect name for PostgreSQL. PostgreSQLDialect DatabaseDialect = "postgres" // MySQLDialect is the dialect name for MySQL. MySQLDialect DatabaseDialect = "mysql" // SQLiteDialect is the dialect name for SQLite. SQLiteDialect DatabaseDialect = "sqlite3" )
type EmailConfiguration ¶
type EmailConfiguration struct { Username string Password string EmailServer string Port int From string }
EmailConfiguration holds email config
type Environment ¶
type Environment string
Environment represents an application environment.
const ( // Development environment Development Environment = "development" // Test environment Test Environment = "test" // Production environment Production Environment = "production" )
type LogConfiguration ¶
type LogConfiguration struct { Level string `json:"level"` Runtime string `json:"runtime"` // dev, prod, gcp, azure, aws }
LogConfiguration holds log config
type ServiceConfiguration ¶
type ServiceConfiguration struct { ServiceName string `json:"name"` Version string `json:"version"` Environment Environment `json:"environment"` Log LogConfiguration Database DatabaseConfiguration Email EmailConfiguration Services map[string]Service Features map[string]Feature }
TODO: use proto to define config.yaml schema ServiceConfiguration is the top level configuration struct which is loaded from the defined source(s)