config

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 5 Imported by: 33

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

func LoadFile(config interface{}, file string, opts Options) error

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

func LoadFiles(config interface{}, files []string, opts Options) error

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.

Types

type Options

type Options struct {
	DisableUnmarshalStrict bool
	DisableValidate        bool
}

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

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 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.
Package listenaddress provides a configuration struct for resolving a listen address from YAML.
Package listenaddress provides a configuration struct for resolving a listen address from YAML.

Jump to

Keyboard shortcuts

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