Documentation
¶
Index ¶
Constants ¶
const ( // ConfigTagName is the name of the field tag to use for config values ConfigTagName = "config" // TagValueSquash is the tag value used when squashing embedded structs TagValueSquash = ",squash" )
Variables ¶
var Version string = "unknown"
Version is set by ldflags, do not set / use this directly use the value exposed from the Base config
Functions ¶
func RegisterDefault ¶
func RegisterDefault(key string, value interface{})
RegisterDefault registers a default value for a configuration key
func RegisterDefaults ¶
func RegisterDefaults(kvs map[string]interface{})
RegisterDefaults register the set of default key/value pairs
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
SetEnvPrefix sets the prefix to env vars that are searched
Types ¶
type Base ¶
type Base struct {
Env Env `config:"env"`
LogLevel string `config:"log_level"`
ExportRuntimeMetrics bool `config:"export_runtime_metrics"`
ProjectID string `config:"project_id"`
ServiceOwner string `config:"service_owner"`
ServiceName string `config:"service_name"`
SystemPort int `config:"system_port"`
TraceAddress string `config:"host_ip"`
TraceMaxBatchCount int `config:"trace_max_batch_count"`
TraceSampleRate float64 `config:"trace_sample_rate"`
ProfilerEnabled bool `config:"profiler_enabled"`
ProfilerBlockProfileRate int `config:"profiler_block_profile_rate"`
ProfilerMutexProfileFraction int `config:"profiler_mutex_profile_fraction"`
DisableLogSampling bool `config:"disable_log_sampling"`
DisableStackTraces bool `config:"disable_stack_traces"`
Version string `config:"version"`
}
Base is the base configuration for all services
type Config ¶
type Config interface {
Get(key string) interface{}
GetBool(key string) bool
GetFloat64(key string) float64
GetInt(key string) int
GetInt32(key string) int32
GetInt64(key string) int64
GetUint(key string) uint
GetUint32(key string) uint32
GetUint64(key string) uint64
GetString(key string) string
GetStringMap(key string) map[string]interface{}
GetStringMapString(key string) map[string]string
GetStringSlice(key string) []string
GetTime(key string) time.Time
GetDuration(key string) time.Duration
IsSet(key string) bool
Set(key string, value interface{})
Bind(to interface{}) error
Debug()
SetSecure(key string)
WriteTo(w io.Writer) (int64, error)
}
Config provides access to application configuration information
type Env ¶
type Env string
Env is an environment string
func (*Env) UnmarshalConfig ¶
UnmarshalConfig unmarshals a config value string to the associated interface type
type Loader ¶
type Loader interface {
RegisterDefault(key string, value interface{})
RegisterDefaults(kvs map[string]interface{})
SetEnvPrefix(string)
Load(flags *pflag.FlagSet) (Config, error)
LoadInto(flags *pflag.FlagSet, to interface{}) error
LoadedConfig() Config
}
Loader loads configurations from multiple sources
func NewFileLoader ¶
NewFileLoader creates a new config Loader instance with the supplied config file
type Option ¶
type Option func(*options)
Option is a configuration option for the metrics system
func WithHTTPServer ¶
WithHTTPServer passes the http.Server to bind to
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalConfig(value string)
}
Unmarshaler describes a custom Unmarshal function that can be used to bind config values