Skip to content

Latest commit

 

History

History

config

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

config

-- import "github.com/Clever/sphinx/config"

Usage

func ValidateConfig

func ValidateConfig(config Config) error

ValidateConfig validates that a Config has all the required fields TODO (z): These should all be private, but right now tests depend on parsing bytes into yaml

type Config

type Config struct {
	Proxy       Proxy
	HealthCheck HealthCheck `yaml:"health-check"`
	Limits      map[string]Limit
	Storage     map[string]string
}

Config holds the yaml data for the config file

func LoadAndValidateYaml

func LoadAndValidateYaml(data []byte) (Config, error)

LoadAndValidateYaml turns a sequence of bytes into a Config and validates that all the necessary fields are set TODO (z): These should all be private, but right now tests depend on parsing bytes into yaml

func LoadYaml

func LoadYaml(data []byte) (Config, error)

LoadYaml loads byte data for a yaml file into a Config TODO (z): These should all be private, but right now tests depend on parsing bytes into yaml

func New

func New(path string) (Config, error)

New takes in a path to a configuration yaml and returns a Configuration.

type HealthCheck

type HealthCheck struct {
	Port     string
	Endpoint string
	Enabled  bool
}

HealthCheck holds the yaml data for how to run the health check service.

type Limit

type Limit struct {
	Interval uint
	Max      uint
	Keys     map[string]interface{}
	Matches  map[string]interface{}
	Excludes map[string]interface{}
}

Limit holds the yaml data for one of the limits in the config file

type Proxy

type Proxy struct {
	Handler      string
	Host         string
	Listen       string
	AllowOnError bool `yaml:"allow-on-error"`
}

Proxy holds the yaml data for the proxy option in the config file