Documentation ¶
Index ¶
- Constants
- Variables
- func Exists[T comparable, V any](map_ map[T]V, key T) bool
- func GetDefaultConfigFilePath(filename string) string
- func If[T any](predicate bool, truthy, falsy T) T
- func VersionInfo() string
- type API
- type AcceptancePolicy
- type Client
- type CompatibilityPolicy
- type Config
- func (c *Config) InitConfig(ctx context.Context)
- func (c *Config) LoadDefaults(ctx context.Context)
- func (c *Config) LoadGlobalConfigFile(ctx context.Context)
- func (c *Config) LoadGlobalEnvVars(ctx context.Context)
- func (c *Config) LoadPluginConfigFile(ctx context.Context)
- func (c *Config) LoadPluginEnvVars(ctx context.Context)
- func (c *Config) MergeGlobalConfig(ctx context.Context, updatedGlobalConfig map[string]interface{})
- func (c *Config) UnmarshalGlobalConfig(ctx context.Context)
- func (c *Config) UnmarshalPluginConfig(ctx context.Context)
- func (c *Config) ValidateGlobalConfig(ctx context.Context)
- type GlobalConfig
- type IConfig
- type LogOutput
- type Logger
- type Metrics
- type Plugin
- type PluginConfig
- type Pool
- type Proxy
- type Server
- type Status
- type TerminationPolicy
- type VerificationPolicy
Constants ¶
const ( // Config constants. Default = "default" EnvPrefix = "GATEWAYD_" TracerName = "gatewayd" GlobalConfigFilename = "gatewayd.yaml" PluginsConfigFilename = "gatewayd_plugins.yaml" // Logger constants. DefaultLogOutput = "console" DefaultLogFileName = "gatewayd.log" DefaultLogLevel = "info" DefaultNoColor = false DefaultTimeFormat = "unix" DefaultConsoleTimeFormat = "RFC3339" DefaultMaxSize = 500 // megabytes DefaultMaxBackups = 5 DefaultMaxAge = 30 // days DefaultCompress = true DefaultLocalTime = false DefaultSyslogTag = "gatewayd" DefaultRSyslogNetwork = "tcp" DefaultRSyslogAddress = "localhost:514" DefaultSyslogPriority = "info" // Plugin constants. DefaultMinPort = 50000 DefaultMaxPort = 60000 PluginPriorityStart = 1000 LoggerName = "plugin" DefaultPluginAddress = "http://plugins/metrics" DefaultMetricsMergerPeriod = 5 * time.Second DefaultPluginHealthCheckPeriod = 5 * time.Second DefaultPluginTimeout = 30 * time.Second DefaultPluginStartTimeout = 1 * time.Minute // Client constants. DefaultNetwork = "tcp" DefaultAddress = "localhost:5432" DefaultChunkSize = 8192 DefaultReceiveDeadline = 0 // 0 means no deadline (timeout) DefaultSendDeadline = 0 DefaultTCPKeepAlivePeriod = 30 * time.Second DefaultTCPKeepAlive = false DefaultReceiveTimeout = 0 DefaultDialTimeout = 60 * time.Second DefaultRetries = 3 DefaultBackoff = 1 * time.Second DefaultBackoffMultiplier = 2.0 DefaultDisableBackoffCaps = false // Pool constants. EmptyPoolCapacity = 0 DefaultPoolSize = 10 MinimumPoolSize = 2 DefaultHealthCheckPeriod = 60 * time.Second // This must match PostgreSQL authentication timeout. // Server constants. DefaultListenNetwork = "tcp" DefaultListenAddress = "0.0.0.0:15432" DefaultTickInterval = 5 * time.Second DefaultBufferSize = 1 << 27 // 134217728 bytes DefaultTCPKeepAliveDuration = 3 * time.Second DefaultLoadBalancer = "roundrobin" DefaultTCPNoDelay = true DefaultEngineStopTimeout = 5 * time.Second DefaultHandshakeTimeout = 5 * time.Second // Utility constants. DefaultSeed = 1000 ChecksumBufferSize = 65536 // Metrics constants. DefaultMetricsAddress = "localhost:9090" DefaultMetricsPath = "/metrics" DefaultReadHeaderTimeout = 10 * time.Second DefaultMetricsServerTimeout = 10 * time.Second // Sentry constants. DefaultTraceSampleRate = 0.2 DefaultAttachStacktrace = true DefaultFlushTimeout = 2 * time.Second // API constants. DefaultHTTPAPIAddress = "localhost:18080" DefaultGRPCAPINetwork = "tcp" DefaultGRPCAPIAddress = "localhost:19090" // Policies. DefaultCompatibilityPolicy = Strict DefaultVerificationPolicy = PassDown DefaultAcceptancePolicy = Accept DefaultTerminationPolicy = Stop )
const Name = "GatewayD"
Variables ¶
var ( CompatibilityPolicies = map[string]CompatibilityPolicy{ "strict": Strict, "loose": Loose, } VerificationPolicies = map[string]VerificationPolicy{ "passdown": PassDown, "ignore": Ignore, "abort": Abort, "remove": Remove, } AcceptancePolicies = map[string]AcceptancePolicy{ "accept": Accept, "reject": Reject, } TerminationPolicies = map[string]TerminationPolicy{ "continue": Continue, "stop": Stop, } TimeFormats = map[string]string{ "": zerolog.TimeFormatUnix, "unix": zerolog.TimeFormatUnix, "unixms": zerolog.TimeFormatUnixMs, "unixmicro": zerolog.TimeFormatUnixMicro, "unixnano": zerolog.TimeFormatUnixNano, } ConsoleTimeFormats = map[string]string{ "Layout": time.Layout, "ANSIC": time.ANSIC, "UnixDate": time.UnixDate, "RubyDate": time.RubyDate, "RFC822": time.RFC822, "RFC822Z": time.RFC822Z, "RFC850": time.RFC850, "RFC1123": time.RFC1123, "RFC1123Z": time.RFC1123Z, "RFC3339": time.RFC3339, "RFC3339Nano": time.RFC3339Nano, "Kitchen": time.Kitchen, "Stamp": time.Stamp, "StampMilli": time.StampMilli, "StampMicro": time.StampMicro, "StampNano": time.StampNano, } LogLevels = map[string]zerolog.Level{ "trace": zerolog.TraceLevel, "debug": zerolog.DebugLevel, "info": zerolog.InfoLevel, "warn": zerolog.WarnLevel, "error": zerolog.ErrorLevel, "fatal": zerolog.FatalLevel, "panic": zerolog.PanicLevel, "disabled": zerolog.Disabled, } )
var ( // Version is the semantic version of GatewayD. Version = "0.0.0" // VersionDetails is the build timestamp and the tagged commit hash. VersionDetails = "" )
Functions ¶
func Exists ¶ added in v0.8.6
func Exists[T comparable, V any](map_ map[T]V, key T) bool
Exists returns true if key exists in map_, false otherwise.
func GetDefaultConfigFilePath ¶ added in v0.6.5
GetDefaultConfigFilePath returns the path of the default config file.
func VersionInfo ¶ added in v0.3.1
func VersionInfo() string
VersionInfo returns the full version and build information for the currently running GatewayD executable.
Types ¶
type AcceptancePolicy ¶ added in v0.2.4
type AcceptancePolicy string
const ( Accept AcceptancePolicy = "accept" // Accept all custom hooks Reject AcceptancePolicy = "reject" // Reject all custom hooks )
AcceptancePolicy is the acceptance policy for custom hooks.
type Client ¶
type Client struct { Network string `json:"network" jsonschema:"enum=tcp,enum=udp,enum=unix"` Address string `json:"address"` TCPKeepAlive bool `json:"tcpKeepAlive"` TCPKeepAlivePeriod time.Duration `json:"tcpKeepAlivePeriod" jsonschema:"oneof_type=string;integer"` ReceiveChunkSize int `json:"receiveChunkSize"` ReceiveDeadline time.Duration `json:"receiveDeadline" jsonschema:"oneof_type=string;integer"` ReceiveTimeout time.Duration `json:"receiveTimeout" jsonschema:"oneof_type=string;integer"` SendDeadline time.Duration `json:"sendDeadline" jsonschema:"oneof_type=string;integer"` DialTimeout time.Duration `json:"dialTimeout" jsonschema:"oneof_type=string;integer"` Retries int `json:"retries"` Backoff time.Duration `json:"backoff" jsonschema:"oneof_type=string;integer"` BackoffMultiplier float64 `json:"backoffMultiplier"` DisableBackoffCaps bool `json:"disableBackoffCaps"` }
type CompatibilityPolicy ¶ added in v0.2.4
type CompatibilityPolicy string
const ( Strict CompatibilityPolicy = "strict" // Expect all required plugins to be loaded and present Loose CompatibilityPolicy = "loose" // Load the plugin, even if the requirements are not met )
CompatibilityPolicy is the compatibility policy for plugins.
type Config ¶ added in v0.3.1
type Config struct { GlobalKoanf *koanf.Koanf PluginKoanf *koanf.Koanf Global GlobalConfig Plugin PluginConfig // contains filtered or unexported fields }
func (*Config) InitConfig ¶ added in v0.4.5
func (*Config) LoadDefaults ¶ added in v0.3.1
LoadDefaults loads the default configuration before loading the config files.
func (*Config) LoadGlobalConfigFile ¶ added in v0.3.1
LoadGlobalConfig loads the plugin configuration file.
func (*Config) LoadGlobalEnvVars ¶ added in v0.3.1
LoadGlobalEnvVars loads the environment variables into the global configuration with the given prefix, "GATEWAYD_".
func (*Config) LoadPluginConfigFile ¶ added in v0.3.1
LoadPluginConfig loads the plugin configuration file.
func (*Config) LoadPluginEnvVars ¶ added in v0.3.1
LoadPluginEnvVars loads the environment variables into the plugins configuration with the given prefix, "GATEWAYD_".
func (*Config) MergeGlobalConfig ¶ added in v0.3.1
func (*Config) UnmarshalGlobalConfig ¶ added in v0.3.1
UnmarshalGlobalConfig unmarshals the global configuration for easier access.
func (*Config) UnmarshalPluginConfig ¶ added in v0.3.1
UnmarshalPluginConfig unmarshals the plugin configuration for easier access.
func (*Config) ValidateGlobalConfig ¶ added in v0.6.6
type GlobalConfig ¶
type GlobalConfig struct { API API `json:"api"` Loggers map[string]*Logger `json:"loggers"` Clients map[string]*Client `json:"clients"` Pools map[string]*Pool `json:"pools"` Proxies map[string]*Proxy `json:"proxies"` Servers map[string]*Server `json:"servers"` Metrics map[string]*Metrics `json:"metrics"` }
func (GlobalConfig) Filter ¶ added in v0.8.6
func (gc GlobalConfig) Filter(groupName string) *GlobalConfig
Filter returns a filtered global config based on the group name.
type IConfig ¶ added in v0.3.1
type IConfig interface { InitConfig(ctx context.Context) LoadDefaults(ctx context.Context) LoadPluginEnvVars(ctx context.Context) LoadGlobalEnvVars(ctx context.Context) LoadGlobalConfigFile(ctx context.Context) LoadPluginConfigFile(ctx context.Context) MergeGlobalConfig(ctx context.Context, updatedGlobalConfig map[string]interface{}) }
type Logger ¶
type Logger struct { Output []string `json:"output"` TimeFormat string `json:"timeFormat" jsonschema:"enum=unix,enum=unixms,enum=unixmicro,enum=unixnano"` Level string `json:"level" jsonschema:"enum=trace,enum=debug,enum=info,enum=warn,enum=error,enum=fatal,enum=panic,enum=disabled"` ConsoleTimeFormat string `` /* 253-byte string literal not displayed */ NoColor bool `json:"noColor"` FileName string `json:"fileName"` MaxSize int `json:"maxSize"` MaxBackups int `json:"maxBackups"` MaxAge int `json:"maxAge"` Compress bool `json:"compress"` LocalTime bool `json:"localTime"` RSyslogNetwork string `json:"rsyslogNetwork" jsonschema:"enum=tcp,enum=udp,enum=unix"` RSyslogAddress string `json:"rsyslogAddress"` SyslogPriority string `json:"syslogPriority" jsonschema:"enum=debug,enum=info,enum=notice,enum=warning,enum=err,enum=crit,enum=alert,enum=emerg"` }
func (Logger) GetSyslogPriority ¶ added in v0.3.2
GetSyslogPriority returns the rsyslog facility from config file.
type Metrics ¶ added in v0.3.0
type Metrics struct { Enabled bool `json:"enabled"` Address string `json:"address"` Path string `json:"path"` ReadHeaderTimeout time.Duration `json:"readHeaderTimeout" jsonschema:"oneof_type=string;integer"` Timeout time.Duration `json:"timeout" jsonschema:"oneof_type=string;integer"` CertFile string `json:"certFile"` KeyFile string `json:"keyFile"` }
type PluginConfig ¶
type PluginConfig struct { VerificationPolicy string `json:"verificationPolicy" jsonschema:"enum=passdown,enum=ignore,enum=abort,enum=remove"` CompatibilityPolicy string `json:"compatibilityPolicy" jsonschema:"enum=strict,enum=loose"` AcceptancePolicy string `json:"acceptancePolicy" jsonschema:"enum=accept,enum=reject"` TerminationPolicy string `json:"terminationPolicy" jsonschema:"enum=continue,enum=stop"` EnableMetricsMerger bool `json:"enableMetricsMerger"` MetricsMergerPeriod time.Duration `json:"metricsMergerPeriod" jsonschema:"oneof_type=string;integer"` HealthCheckPeriod time.Duration `json:"healthCheckPeriod" jsonschema:"oneof_type=string;integer"` ReloadOnCrash bool `json:"reloadOnCrash"` Timeout time.Duration `json:"timeout" jsonschema:"oneof_type=string;integer"` StartTimeout time.Duration `json:"startTimeout" jsonschema:"oneof_type=string;integer"` Plugins []Plugin `json:"plugins"` }
func (PluginConfig) GetPlugins ¶ added in v0.5.2
func (p PluginConfig) GetPlugins(name ...string) []Plugin
GetPlugins returns the plugins from config file.
type Server ¶
type Server struct { EnableTicker bool `json:"enableTicker"` TickInterval time.Duration `json:"tickInterval" jsonschema:"oneof_type=string;integer"` Network string `json:"network" jsonschema:"enum=tcp,enum=udp,enum=unix"` Address string `json:"address"` EnableTLS bool `json:"enableTLS"` //nolint:tagliatelle CertFile string `json:"certFile"` KeyFile string `json:"keyFile"` HandshakeTimeout time.Duration `json:"handshakeTimeout" jsonschema:"oneof_type=string;integer"` }
type TerminationPolicy ¶ added in v0.6.4
type TerminationPolicy string
const ( Continue TerminationPolicy = "continue" // Continue to the next function Stop TerminationPolicy = "stop" // Stop the execution of the functions )
TerminationPolicy is the termination policy for the functions registered to the OnTrafficFromClient hook.
type VerificationPolicy ¶ added in v0.2.4
type VerificationPolicy string
const ( // Non-strict (permissive) mode. PassDown VerificationPolicy = "passdown" // Pass down the extra keys/values in result to the next plugins // Strict mode. Ignore VerificationPolicy = "ignore" // Ignore errors and continue Abort VerificationPolicy = "abort" // Abort on first error and return results Remove VerificationPolicy = "remove" // Remove the hook from the list on error and continue )
VerificationPolicy is the policy for hook verification.