Documentation
¶
Overview ¶
Package config provides utilities for loading configuration files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFile ¶
LoadFile loads a config from a file.
Example ¶
package main
import (
"fmt"
"log"
"github.com/m3db/m3/src/x/config"
)
type configuration struct {
ListenAddress string `yaml:"listenAddress" validate:"nonzero"`
}
func main() {
var cfg configuration
file := "testdata/conf.yaml"
if err := config.LoadFile(&cfg, file, config.Options{}); err != nil {
log.Fatal(err)
}
fmt.Printf("listenAddress: %s\n", cfg.ListenAddress)
}
Output: listenAddress: 0.0.0.0:8392
func LoadFiles ¶
LoadFiles loads a config from list of files. If value for a property is present in multiple files, the value from the last file will be applied. Validation is done after merging all values.
func WarnOnDeprecation ¶ added in v0.11.0
WarnOnDeprecation emits a warning for every deprecated field
Types ¶
type Options ¶
type Options struct {
DisableUnmarshalStrict bool
DisableValidate bool
// Expand provides values for templated strings of the form ${KEY}.
// By default, we extract these values from the environment.
Expand config.LookupFunc
}
Options is an options set used when parsing config.
type WorkerPoolPolicy ¶
type WorkerPoolPolicy struct {
// Determines if the worker pool automatically grows to capacity.
GrowOnDemand bool `yaml:"grow"`
// Size for static pools, initial size for dynamically growing pools.
Size int `yaml:"size"`
// The number of shards for the pool.
NumShards int64 `yaml:"shards"`
// The probablility that a worker is killed after completing the task.
KillWorkerProbability float64 `yaml:"killProbability" validate:"min=0.0,max=1.0"`
}
WorkerPoolPolicy specifies the policy for the worker pool.
func (WorkerPoolPolicy) Options ¶
func (w WorkerPoolPolicy) Options() (sync.PooledWorkerPoolOptions, int)
Options converts the worker pool policy to options, providing the options, as well as the default size for the worker pool.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package configflag provides a utility for registering config related command line options with the stdlib flag package.
|
Package configflag provides a utility for registering config related command line options with the stdlib flag package. |
|
Package hostid provides a configuration struct for resolving a host ID from YAML.
|
Package hostid provides a configuration struct for resolving a host ID from YAML. |
Click to show internal directories.
Click to hide internal directories.