config

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VTStructure ValidatorType = "structure"
	VTLookup    ValidatorType = "lookup"

	LFJSON LogFormat = "json"
	LGText LogFormat = "text"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Server struct {
		ListenOn        string   `toml:"listenOn"`
		ConnectionLimit uint     `toml:"connectionLimit"`
		InstanceID      string   `toml:"-"` // Extra identifier used in logs and for instance identification
		MaxRequestSize  uint64   `toml:"maxRequestSize" usage:"Maximum amount of bytes until a HTTP request is accepted"`
		NetTTL          Duration `toml:"netTTL" usage:"Max time to spend on external communication"`
		PathStrip       string   `toml:"pathStrip"`
		Headers         Headers  `toml:"headers" env:"-" usage:"Only (repeatable) flag or config file supported"`
		CORS            struct {
			AllowedOrigins []string `toml:"allowedOrigins"`
			AllowedHeaders []string `toml:"allowedHeaders"`
		} `toml:"CORS"`
		Profiler struct {
			Enable bool   `toml:"enable" default:"false"`
			Prefix string `toml:"prefix"`
		} `toml:"profiler"`
	} `toml:"server" flag:",inline" env:",inline"`
	Log struct {
		Level  string    `toml:"level"`
		Format LogFormat `toml:"format" usage:"The log output format \"json\" or \"text\""`
	} `toml:"log"`
	Hash struct {
		Key string `toml:"key"`
	} `toml:"hash"`
	Finder struct {
		UseBuckets      bool    `toml:"useBuckets" usage:"Buckets speedup matching, but assumes no mistakes are made at the start"`
		LengthTolerance float64 `toml:"lengthTolerance" usage:"percentage, number 0.0-1.0, of length difference to consider"`
	} `toml:"finder"`
	Validator struct {
		Resolver         string        `toml:"resolver" usage:"The resolver to use for DNS lookups"`
		SuggestValidator ValidatorType `toml:"suggest"`
	} `toml:"validator" flag:",inline" env:",inline"`
	Services struct {
		Autocomplete struct {
			RecipientThreshold uint64 `toml:"recipientThreshold" usage:"Define the minimum amount of recipients a domain needs before allowed in the autocomplete"`
			MaxSuggestions     uint64 `toml:"maxSuggestions" usage:"The maximum number of suggestions to return"`
		} `toml:"autocomplete"`
		Suggest struct {
			Prefer Preferred `toml:"prefer" env:"-" usage:"A repeatable flag to create a preference list for common alternatives, example.com=example.org"`
		} `toml:"suggest"`
	} `toml:"services"`
	Backend struct {
		Driver             string `toml:"driver" usage:"List a driver to use, currently supporting: 'memory' or 'postgres'"`
		URL                string `toml:"url"`
		MaxConnections     uint   `toml:"maxConnections"`
		MaxIdleConnections uint   `toml:"maxIdleConnections"`
	} `toml:"backend"`
	GraphQL struct {
		PrettyOutput bool `toml:"prettyOutput" flag:"pretty" env:"PRETTY"`
		GraphiQL     bool `toml:"graphiQL" flag:"graphiql" env:"GRAPHIQL"`
		Playground   bool `toml:"playground"`
	} `toml:"graphql" flag:"graphql" env:"GRAPHQL"`
	RateLimiter struct {
		Rate      int64    `toml:"rate"`
		Capacity  int64    `toml:"capacity"`
		ParkedTTL Duration `toml:"parkedTTL" flag:"parked-ttl"`
	} `toml:"rateLimiter"`
	GCP struct {
		ProjectID       string `toml:"projectId"`
		PubSubTopic     string `toml:"pubSubTopic"`
		CredentialsFile string `toml:"credentialsFile" env:"APPLICATION_CREDENTIALS"`
	} `toml:"GCP" flag:"gcp" env:"GOOGLE"`
}

Config holds central config parameters

func NewConfig

func NewConfig(fileName string) (Config, error)

func (Config) GetSensored

func (c Config) GetSensored() Config

GetSensored returns a copy of Config with all sensitive values masked

func (*Config) String

func (c *Config) String() string

type Duration

type Duration struct {
	// contains filtered or unexported fields
}

func (Duration) AsDuration

func (d Duration) AsDuration() time.Duration

func (*Duration) Set

func (d *Duration) Set(v string) error

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type Headers

type Headers map[string]string

func (*Headers) Set

func (h *Headers) Set(v string) error

func (Headers) String

func (h Headers) String() string

type LogFormat

type LogFormat string

func (*LogFormat) Set

func (vt *LogFormat) Set(v string) error

func (LogFormat) String

func (vt LogFormat) String() string

func (*LogFormat) UnmarshalText

func (vt *LogFormat) UnmarshalText(value []byte) error

type Preferred added in v0.0.11

type Preferred map[string]string

func (*Preferred) Set added in v0.0.11

func (p *Preferred) Set(v string) error

func (Preferred) String added in v0.0.11

func (p Preferred) String() string

type ValidatorType

type ValidatorType string

func (*ValidatorType) Set

func (vt *ValidatorType) Set(v string) error

func (ValidatorType) String

func (vt ValidatorType) String() string

func (*ValidatorType) UnmarshalText

func (vt *ValidatorType) UnmarshalText(value []byte) error

type ValidatorTypes

type ValidatorTypes []ValidatorType

func (ValidatorTypes) AsStringSlice

func (v ValidatorTypes) AsStringSlice() []string

Jump to

Keyboard shortcuts

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