conf

package
v6.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 8 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"`
		QueryResourceTimeout time.Duration `env:"RESTQL_QUERY_RESOURCE_TIMEOUT" envDefault:"5s"`

		GlobalQueryTimeout time.Duration `env:"RESTQL_QUERY_GLOBAL_TIMEOUT" envDefault:"30s"`

		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"`
				TenantByHost        tenantByHostConf        `yaml:"tenantByHost"`
			} `yaml:"middlewares"`
		} `yaml:"server"`

		Client struct {
			MaxConcurrentQueries    int `yaml:"maxConcurrentQueries" env:"RESTQL_MAX_CONCURRENT_QUERIES"`
			MaxConcurrentGoroutines int `yaml:"maxConcurrentGoroutines" env:"RESTQL_MAX_CONCURRENT_GOROUTINES"`

			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"`

	Debugging struct {
		QueryParam bool `yaml:"queryParam" env:"RESTQL_DEBUGGING_QUERY_PARAM"`
		Header     bool `yaml:"header" env:"RESTQL_DEBUGGING_HEADER"`
	} `yaml:"debugging"`

	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 {
		Disable bool `yaml:"disable" env:"RESTQL_CACHE_DISABLE"`

		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"`

	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