config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 62

Documentation

Overview

Package config defines the config structs and some config parser interfaces and implementations

Index

Constants

View Source
const (
	BracketsRouterPatternBuilder = iota
	ColonRouterPatternBuilder
	DefaultMaxIdleConnectionsPerHost = 250
	DefaultTimeout                   = 2 * time.Second
	TurboConfigVersion               = 1
)

Variables

View Source
var ExtraConfigAlias = map[string]string{}
View Source
var RoutingPattern = ColonRouterPatternBuilder

Functions

func CheckErr

func CheckErr(err error, configFile string) error

Types

type Backend

type Backend struct {
	Group                    string            `mapstructure:"group"`
	Method                   string            `mapstructure:"method"`
	Host                     []string          `mapstructure:"host"`
	HostSanitizationDisabled bool              `mapstructure:"disable_host_sanitize"`
	URLPattern               string            `mapstructure:"url_pattern"`
	AllowList                []string          `mapstructure:"allow"`
	DenyList                 []string          `mapstructure:"deny"`
	Mapping                  map[string]string `mapstructure:"mapping"`
	Encoding                 string            `mapstructure:"encoding"`
	IsCollection             bool              `mapstructure:"is_collection"`
	Target                   string            `mapstructure:"target"`
	SD                       string            `mapstructure:"sd"`
	URLKeys                  []string
	ConcurrentCalls          int
	Timeout                  time.Duration
	Decoder                  encoding.Decoder `json:"-"`
	ExtraConfig              ExtraConfig      `mapstructure:"extra_config"`
}

type EndpointConfig

type EndpointConfig struct {
	Endpoint        string        `mapstructure:"endpoint"`
	Method          string        `mapstructure:"method"`
	Backend         []*Backend    `mapstructure:"backend"`
	ConcurrentCalls int           `mapstructure:"concurrent_calls"`
	Timeout         time.Duration `mapstructure:"timeout"`
	CacheTTL        time.Duration `mapstructure:"cache_ttl"`
	QueryString     []string      `mapstructure:"querystring_params"`
	ExtraConfig     ExtraConfig   `mapstructure:"extra_config"`
	HeadersToPass   []string      `mapstructure:"headers_to_pass"`
	OutputEncoding  string        `mapstructure:"output_encoding"`
}

type EndpointMatchError

type EndpointMatchError struct {
	Path   string
	Method string
	Err    error
}

func (*EndpointMatchError) Error

func (e *EndpointMatchError) Error() string

type EndpointPathError

type EndpointPathError struct {
	Path   string
	Method string
}

func (*EndpointPathError) Error

func (e *EndpointPathError) Error() string

type ExtraConfig

type ExtraConfig map[string]interface{}

type FileReaderFunc

type FileReaderFunc func(string) ([]byte, error)

type NoBackendsError

type NoBackendsError struct {
	Path   string
	Method string
}

func (*NoBackendsError) Error

func (n *NoBackendsError) Error() string

type ParseError

type ParseError struct {
	ConfigFile string
	Offset     int
	Row        int
	Col        int
	Err        error
}

func NewParseError

func NewParseError(err error, configFile string, offset int) *ParseError

func (*ParseError) Error

func (p *ParseError) Error() string

type Parser

type Parser interface {
	Parse(configFile string) (ServiceConfig, error)
}

func NewParser

func NewParser() Parser

func NewParserWithFileReader

func NewParserWithFileReader(f FileReaderFunc) Parser

type ParserFunc

type ParserFunc func(string) (ServiceConfig, error)

func (ParserFunc) Parse

func (f ParserFunc) Parse(configFile string) (ServiceConfig, error)

type Plugin

type Plugin struct {
	Folder  string `mapstructure:"folder"`
	Pattern string `mapstructure:"pattern"`
}

type ServiceConfig

type ServiceConfig struct {
	Name                      string            `mapstructure:"name"`
	Endpoints                 []*EndpointConfig `mapstructure:"endpoints"`
	Timeout                   time.Duration     `mapstructure:"timeout"`
	CacheTTL                  time.Duration     `mapstructure:"cache_ttl"`
	Host                      []string          `mapstructure:"host"`
	Port                      int               `mapstructure:"port"`
	Version                   int               `mapstructure:"version"`
	OutputEncoding            string            `mapstructure:"output_encoding"`
	ExtraConfig               ExtraConfig       `mapstructure:"extra_config"`
	ReadTimeout               time.Duration     `mapstructure:"read_timeout"`
	WriteTimeout              time.Duration     `mapstructure:"write_timeout"`
	IdleTimeout               time.Duration     `mapstructure:"idle_timeout"`
	ReadHeaderTimeout         time.Duration     `mapstructure:"read_header_timeout"`
	DisableKeepAlives         bool              `mapstructure:"disable_keep_alives"`
	DisableCompression        bool              `mapstructure:"disable_compression"`
	MaxIdleConnections        int               `mapstructure:"max_idle_connections"`
	MaxIdleConnectionsPerHost int               `mapstructure:"max_idle_connections_per_host"`
	IdleConnectionTimeout     time.Duration     `mapstructure:"idle_connection_timeout"`
	ResponseHeaderTimeout     time.Duration     `mapstructure:"response_header_timeout"`
	ExpectContinueTimeout     time.Duration     `mapstructure:"expect_continue_timeout"`
	DialerTimeout             time.Duration     `mapstructure:"dialer_timeout"`
	DialerFallbackDelay       time.Duration     `mapstructure:"dialer_fallback_delay"`
	DialerKeepAlive           time.Duration     `mapstructure:"dialer_keep_alive"`
	DisableStrictREST         bool              `mapstructure:"disable_rest"`
	Plugin                    *Plugin           `mapstructure:"plugin"`
	TLS                       *TLS              `mapstructure:"tls"`
	Debug                     bool
	// contains filtered or unexported fields
}

func (*ServiceConfig) Hash

func (s *ServiceConfig) Hash() (string, error)

func (*ServiceConfig) Init

func (s *ServiceConfig) Init() error

type TLS

type TLS struct {
	IsDisabled               bool     `mapstructure:"disabled"`
	PublicKey                string   `mapstructure:"public_key"`
	PrivateKey               string   `mapstructure:"private_key"`
	MinVersion               string   `mapstructure:"min_version"`
	MaxVersion               string   `mapstructure:"max_version"`
	CurvePreferences         []uint16 `mapstructure:"curve_preferences"`
	PreferServerCipherSuites bool     `mapstructure:"prefer_server_cipher_suites"`
	CipherSuites             []uint16 `mapstructure:"cipher_suites"`
	EnableMTLS               bool     `mapstructure:"enable_mtls"`
}

type URI

type URI int

func (URI) CleanHost

func (URI) CleanHost(host string) string

func (URI) CleanHosts

func (u URI) CleanHosts(hosts []string) []string

func (URI) CleanPath

func (URI) CleanPath(path string) string

func (URI) GetEndpointPath

func (u URI) GetEndpointPath(path string, params []string) string

type URIParser

type URIParser interface {
	CleanHosts([]string) []string
	CleanHost(string) string
	CleanPath(string) string
	GetEndpointPath(string, []string) string
}

func NewURIParser

func NewURIParser() URIParser

type UndefinedOutputParamError

type UndefinedOutputParamError struct {
	Endpoint     string
	Method       string
	Backend      int
	InputParams  []string
	OutputParams []string
	Param        string
}

func (*UndefinedOutputParamError) Error

func (u *UndefinedOutputParamError) Error() string

type UnsupportedVersionError

type UnsupportedVersionError struct {
	Have int
	Want int
}

func (*UnsupportedVersionError) Error

func (u *UnsupportedVersionError) Error() string

type WrongNumberOfParamsError

type WrongNumberOfParamsError struct {
	Endpoint     string
	Method       string
	Backend      int
	InputParams  []string
	OutputParams []string
}

func (*WrongNumberOfParamsError) Error

func (w *WrongNumberOfParamsError) Error() string

Jump to

Keyboard shortcuts

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