Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultConfigFilePath(filename string) string
- 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
- func (p PluginConfig) GetAcceptancePolicy() AcceptancePolicy
- func (p PluginConfig) GetPluginCompatibilityPolicy() CompatibilityPolicy
- func (p PluginConfig) GetPlugins(name ...string) []Plugin
- func (p PluginConfig) GetTerminationPolicy() TerminationPolicy
- func (p PluginConfig) GetVerificationPolicy() VerificationPolicy
- 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 // Client constants. DefaultNetwork = "tcp" DefaultAddress = "localhost:5432" DefaultChunkSize = 8192 DefaultReceiveDeadline = 0 // 0 means no deadline (timeout) DefaultSendDeadline = 0 DefaultTCPKeepAlivePeriod = 30 * time.Second DefaultTCPKeepAlive = 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 // Utility constants. DefaultSeed = 1000 ChecksumBufferSize = 65536 // Metrics constants. DefaultMetricsAddress = "localhost:9090" DefaultMetricsPath = "/metrics" // Sentry constants. DefaultTraceSampleRate = 0.2 DefaultAttachStacktrace = true DefaultFlushTimeout = 2 * time.Second // API constants. DefaultHTTPAPIAddress = "localhost:18080" DefaultGRPCAPINetwork = "tcp" DefaultGRPCAPIAddress = "localhost:19090" )
const Name = "GatewayD"
Variables ¶
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 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"` SendDeadline time.Duration `json:"sendDeadline" jsonschema:"oneof_type=string;integer"` }
func (Client) GetReceiveChunkSize ¶ added in v0.6.7
GetReceiveChunkSize returns the receive chunk size from config file or default value.
func (Client) GetReceiveDeadline ¶ added in v0.6.7
GetReceiveDeadline returns the receive deadline from config file or default value.
func (Client) GetSendDeadline ¶ added in v0.6.7
GetSendDeadline returns the send deadline from config file or default value.
func (Client) GetTCPKeepAlivePeriod ¶ added in v0.6.7
GetTCPKeepAlivePeriod returns the TCP keep alive period from config file or default value.
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"` }
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) GetConsoleTimeFormat ¶ added in v0.3.2
GetConsoleTimeFormat returns the console logger's time format from config file.
func (Logger) GetSyslogPriority ¶ added in v0.3.2
GetSyslogPriority returns the rsyslog facility from config file.
func (Logger) GetTimeFormat ¶
GetTimeFormat returns the logger time format from config file.
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"` Plugins []Plugin `json:"plugins"` }
func (PluginConfig) GetAcceptancePolicy ¶ added in v0.2.4
func (p PluginConfig) GetAcceptancePolicy() AcceptancePolicy
GetAcceptancePolicy returns the acceptance policy from plugin config file.
func (PluginConfig) GetPluginCompatibilityPolicy ¶ added in v0.2.4
func (p PluginConfig) GetPluginCompatibilityPolicy() CompatibilityPolicy
GetPluginCompatibilityPolicy returns the plugin compatibility policy from plugin config file.
func (PluginConfig) GetPlugins ¶ added in v0.5.2
func (p PluginConfig) GetPlugins(name ...string) []Plugin
GetPlugins returns the plugins from config file.
func (PluginConfig) GetTerminationPolicy ¶ added in v0.6.6
func (p PluginConfig) GetTerminationPolicy() TerminationPolicy
GetTerminationPolicy returns the termination policy from plugin config file.
func (PluginConfig) GetVerificationPolicy ¶
func (p PluginConfig) GetVerificationPolicy() VerificationPolicy
GetVerificationPolicy returns the hook verification policy from plugin config file.
type Proxy ¶
type Proxy struct { Elastic bool `json:"elastic"` ReuseElasticClients bool `json:"reuseElasticClients"` HealthCheckPeriod time.Duration `json:"healthCheckPeriod" jsonschema:"oneof_type=string;integer"` }
func (Proxy) GetHealthCheckPeriod ¶ added in v0.6.7
GetHealthCheckPeriod returns the health check period from config file or default value.
type Server ¶
type Server struct { EnableTicker bool `json:"enableTicker"` MultiCore bool `json:"multiCore"` LockOSThread bool `json:"lockOSThread"` //nolint:tagliatelle ReuseAddress bool `json:"reuseAddress"` ReusePort bool `json:"reusePort"` TCPNoDelay bool `json:"tcpNoDelay"` ReadBufferCap int `json:"readBufferCap"` WriteBufferCap int `json:"writeBufferCap"` SocketRecvBuffer int `json:"socketRecvBuffer"` SocketSendBuffer int `json:"socketSendBuffer"` SoftLimit uint64 `json:"softLimit"` HardLimit uint64 `json:"hardLimit"` TCPKeepAlive time.Duration `json:"tcpKeepAlive" jsonschema:"oneof_type=string;integer"` 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"` LoadBalancer string `json:"loadBalancer" jsonschema:"enum=roundrobin,enum=leastconnections,enum=sourceaddrhash"` }
func (Server) GetLoadBalancer ¶
func (s Server) GetLoadBalancer() gnet.LoadBalancing
GetLoadBalancer returns the load balancing algorithm to use.
func (Server) GetRLimits ¶ added in v0.6.7
GetSystemLimits returns the current system limits or the configured limits.
func (Server) GetTCPNoDelay ¶
func (s Server) GetTCPNoDelay() gnet.TCPSocketOpt
GetTCPNoDelay returns the TCP no delay option from config file.
func (Server) GetTickInterval ¶ added in v0.6.7
GetTickInterval returns the tick interval from config file or default value.
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.