conf

package
v4.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 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"`
			Admin           struct {
				Enable            bool   `yaml:"enable" env:"RESTQL_ADMIN_ENABLE"`
				AuthorizationCode string `yaml:"authorizationCode" env:"RESTQL_ADMIN_AUTHORIZATION_CODE"`
			} `yaml:"admin"`

			GracefulShutdownTimeout time.Duration `yaml:"gracefulShutdownTimeout"`
			ReadTimeout             time.Duration `yaml:"readTimeout"`
			IdleTimeout             time.Duration `yaml:"idleTimeout"`

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

		Client struct {
			DnsRefreshInterval  time.Duration `yaml:"dnsRefreshInterval"`
			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 {
		DisableDatabase bool `yaml:"disableDatabase" env:"RESTQL_PLUGINS_DATABASE_DISABLE"`
	} `yaml:"plugins"`

	Tenant string `env:"RESTQL_TENANT"`

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

	TenantMappings map[string]map[string]string `yaml:"tenants"`

	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