conf

package
v4.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTP struct {
		ForwardPrefix        string        `yaml:"forwardPrefix" env:"RESTQL_FORWARD_PREFIX"`
		GlobalQueryTimeout   time.Duration `env:"RESTQL_QUERY_GLOBAL_TIMEOUT" envDefault:"30s"`
		QueryResourceTimeout time.Duration `env:"RESTQL_QUERY_RESOURCE_TIMEOUT" envDefault:"5s"`

		Server struct {
			APIAddr                 string        `env:"RESTQL_PORT,required"`
			APIHealthAddr           string        `env:"RESTQL_HEALTH_PORT,required"`
			PropfAddr               string        `env:"RESTQL_PPROF_PORT"`
			EnablePprof             bool          `env:"RESTQL_ENABLE_PPROF"`
			EnableFullPprof         bool          `env:"RESTQL_ENABLE_FULL_PPROF"`
			GracefulShutdownTimeout time.Duration `yaml:"gracefulShutdownTimeout"`
			ReadTimeout             time.Duration `yaml:"readTimeout"`

			Middlewares struct {
				RequestID *requestIDConf `yaml:"requestId"`
				Timeout   *timeoutConf   `yaml:"timeout"`
				Cors      *corsConf      `yaml:"cors"`
			} `yaml:"middlewares"`
		} `yaml:"server"`

		Client struct {
			ConnTimeout         time.Duration `yaml:"connectionTimeout"`
			MaxRequestTimeout   time.Duration `yaml:"maxRequestTimeout"`
			MaxConnsPerHost     int           `yaml:"maxConnectionsPerHost"`
			MaxIdleConns        int           `yaml:"maxIdleConnections"`
			MaxIdleConnsPerHost int           `yaml:"maxIdleConnectionsPerHost"`
			MaxIdleConnDuration time.Duration `yaml:"maxIdleConnectionDuration"`
		} `yaml:"client"`
	} `yaml:"http"`

	Logging struct {
		Enable               bool   `yaml:"enable" env:"RESTQL_LOGGING_ENABLE"`
		TimestampFieldName   string `yaml:"timestampFieldName"`
		TimestampFieldFormat string `yaml:"timestampFieldFormat"`
		Level                string `yaml:"level" env:"RESTQL_LOGGING_LEVEL"`
		Format               string `yaml:"format"`
	} `yaml:"logging"`

	Cache struct {
		Mappings struct {
			MaxSize            int           `yaml:"maxSize" env:"RESTQL_CACHE_MAPPINGS_MAX_SIZE"`
			Expiration         time.Duration `yaml:"expiration" env:"RESTQL_CACHE_MAPPINGS_EXPIRATION"`
			RefreshInterval    time.Duration `yaml:"refreshInterval" env:"RESTQL_CACHE_MAPPINGS_REFRESH_INTERVAL"`
			RefreshQueueLength int           `yaml:"refreshQueueLength" env:"RESTQL_CACHE_MAPPINGS_REFRESH_QUEUE_LENGTH"`
		} `yaml:"mappings"`
		Query struct {
			MaxSize int `yaml:"maxSize" env:"RESTQL_CACHE_QUERY_MAX_SIZE"`
		} `yaml:"query"`
		Parser struct {
			MaxSize int `yaml:"maxSize" env:"RESTQL_CACHE_PARSER_MAX_SIZE"`
		} `yaml:"parser"`
	} `yaml:"cache"`

	Plugins struct {
		Location string `yaml:"location" env:"RESTQL_PLUGINS_LOCATION"`
	} `yaml:"plugins"`

	Tenant string `env:"RESTQL_TENANT"`

	Mappings map[string]string `yaml:"mappings"`

	Queries map[string]map[string][]string `yaml:"queries"`

	Env EnvSource

	Build string
}

Config represents all parameters allowed in restQL runtime.

func Load

func Load(build string) (*Config, error)

Load returns a Config build from the defaults, YAML configuration file and environment variables.

type EnvSource

type EnvSource struct{}

EnvSource allows access to environment variables.

func (EnvSource) GetAll

func (e EnvSource) GetAll() map[string]string

GetAll return all the environment variables.

func (EnvSource) GetString

func (e EnvSource) GetString(key string) string

GetString returns the environment variable value for the given key.

Jump to

Keyboard shortcuts

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