config

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFile = "conf/config-default.yaml"
)
View Source
const HTTPDataPlaneV1Profile = "http-data-plane-v1"

Variables

This section is empty.

Functions

func CapabilitySummary

func CapabilitySummary(cfg *Config) map[string]any

func EffectiveConfigProvider

func EffectiveConfigProvider(cfg *Config) (string, error)

func StandaloneBuckets

func StandaloneBuckets() []string

StandaloneBuckets returns the buckets owned by the standalone configuration file. The returned slice is independent from the package-level definition.

func StandaloneConfigFile

func StandaloneConfigFile(provider string) string

Types

type Admin

type Admin struct {
	AdminKeyRequired bool         `mapstructure:"admin_key_required"`
	AdminKey         []AdminKey   `mapstructure:"admin_key"`
	EnableAdminCORS  bool         `mapstructure:"enable_admin_cors"`
	EnableAdminUI    bool         `mapstructure:"enable_admin_ui"`
	AllowAdmin       []string     `mapstructure:"allow_admin"`
	AdminListen      AdminListen  `mapstructure:"admin_listen"`
	HTTPSAdmin       bool         `mapstructure:"https_admin"`
	AdminAPIMTLS     AdminAPIMTLS `mapstructure:"admin_api_mtls"`
	AdminAPIVersion  string       `mapstructure:"admin_api_version"`
}

type AdminAPIMTLS

type AdminAPIMTLS struct {
	AdminSSLCert    string `mapstructure:"admin_ssl_cert"`
	AdminSSLCertKey string `mapstructure:"admin_ssl_cert_key"`
	AdminSSLCA      string `mapstructure:"admin_ssl_ca_cert"`
}

type AdminKey

type AdminKey struct {
	Name string `mapstructure:"name"`
	Key  string `mapstructure:"key"`
	Role string `mapstructure:"role"`
}

type AdminListen

type AdminListen struct {
	IP   string `mapstructure:"ip"`
	Port int    `mapstructure:"port"`
}

type Apisix

type Apisix struct {
	ID                                 string        `mapstructure:"id"`
	NodeListen                         []NodeListen  `mapstructure:"node_listen"`
	EnableAdmin                        bool          `mapstructure:"enable_admin"`
	EnableDevMode                      bool          `mapstructure:"enable_dev_mode"`
	EnableReuseport                    bool          `mapstructure:"enable_reuseport"`
	ShowUpstreamStatusInResponseHeader bool          `mapstructure:"show_upstream_status_in_response_header"`
	EnableIpv6                         bool          `mapstructure:"enable_ipv6"`
	EnableHttp2                        bool          `mapstructure:"enable_http2"`
	EnableServerTokens                 bool          `mapstructure:"enable_server_tokens"`
	ExtraLuaPath                       string        `mapstructure:"extra_lua_path"`
	ExtraLuaCpath                      string        `mapstructure:"extra_lua_cpath"`
	LuaModuleHook                      string        `mapstructure:"lua_module_hook"`
	ProxyProtocol                      ProxyProtocol `mapstructure:"proxy_protocol"`
	ProxyCache                         ProxyCache    `mapstructure:"proxy_cache"`
	DeleteURITailSlash                 bool          `mapstructure:"delete_uri_tail_slash"`
	NormalizeURILikeServlet            bool          `mapstructure:"normalize_uri_like_servlet"`
	MatchURIEncodedSlash               bool          `mapstructure:"match_uri_encoded_slash"`
	MaxPostArgsReadableSize            int           `mapstructure:"max_post_args_readable_size"`

	Router                              Router         `mapstructure:"router"`
	ProxyMode                           string         `mapstructure:"proxy_mode"`
	StreamProxy                         StreamProxy    `mapstructure:"stream_proxy"`
	DnsResolver                         []string       `mapstructure:"dns_resolver"`
	DnsResolverValid                    int            `mapstructure:"dns_resolver_valid"`
	ResolverTimeout                     int            `mapstructure:"resolver_timeout"`
	EnableResolvSearchOpt               bool           `mapstructure:"enable_resolv_search_opt"`
	Ssl                                 Ssl            `mapstructure:"ssl"`
	EnableControl                       bool           `mapstructure:"enable_control"`
	Control                             Control        `mapstructure:"control"`
	DisableSyncConfigurationDuringStart bool           `mapstructure:"disable_sync_configuration_during_start"`
	WorkerStartupTimeThreshold          int            `mapstructure:"worker_startup_time_threshold"`
	DataEncryption                      DataEncryption `mapstructure:"data_encryption"`
	LRU                                 LRU            `mapstructure:"lru"`
	Tracing                             bool           `mapstructure:"tracing"`
	Status                              Status         `mapstructure:"status"`
	DisableUpstreamHealthcheck          bool           `mapstructure:"disable_upstream_healthcheck"`
	TrustedAddresses                    []string       `mapstructure:"trusted_addresses"`
}

func (Apisix) ListenAddresses

func (a Apisix) ListenAddresses() []string

type Config

type Config struct {
	Debug       bool        `mapstructure:"debug"`
	Apisix      Apisix      `mapstructure:"apisix"`
	NginxConfig NginxConfig `mapstructure:"nginx_config"`

	// NGINX-only directives are retained for config compatibility; the Go server
	// applies the HTTP timeout settings that have direct net/http equivalents.
	Proxy Proxy `mapstructure:"proxy"`

	Discovery     Discovery `mapstructure:"discovery"`
	GraphQL       GraphQL   `mapstructure:"graphql"`
	ExtPlugin     ExtPlugin `mapstructure:"ext-plugin"`
	Wasm          Wasm      `mapstructure:"wasm"`
	XRPC          XRPC      `mapstructure:"xrpc"`
	Events        Events    `mapstructure:"events"`
	Plugins       []string  `mapstructure:"plugins"`
	StreamPlugins []string  `mapstructure:"stream_plugins"`
	// PluginAttr    PluginAttr `mapstructure:"plugin_attr"`
	PluginAttr map[string]map[string]any `mapstructure:"plugin_attr"`
	Deployment Deployment                `mapstructure:"deployment"`
}
var GlobalConfig *Config

func Load

func Load(overridePath string) (*Config, error)

type Control

type Control struct {
	Ip   string `mapstructure:"ip"`
	Port int    `mapstructure:"port"`
}

type DataEncryption

type DataEncryption struct {
	EnableEncryptFields bool     `mapstructure:"enable_encrypt_fields"`
	Keyring             []string `mapstructure:"keyring"`
}

type Deployment

type Deployment struct {
	// TODO: add validation here
	Profile          string                `mapstructure:"profile"`
	Role             string                `mapstructure:"role"`
	RoleTraditional  RoleTraditionalConfig `mapstructure:"role_traditional"`
	RoleDataPlane    RoleConfig            `mapstructure:"role_data_plane"`
	RoleControlPlane RoleConfig            `mapstructure:"role_control_plane"`
	Admin            Admin                 `mapstructure:"admin"`
	Etcd             Etcd                  `mapstructure:"etcd"`
}

type Discovery

type Discovery map[string]any

type Etcd

type Etcd struct {
	Host   []string `mapstructure:"host"`
	Prefix string   `mapstructure:"prefix"`

	// TODO: not support yet
	Timeout            int `mapstructure:"timeout"`
	WatchTimeout       int `mapstructure:"watch_timeout"`
	ResyncDelay        int `mapstructure:"resync_delay"`
	HealthCheckTimeout int `mapstructure:"health_check_timeout"`
	StartupRetry       int `mapstructure:"startup_retry"`

	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`

	// TODO: not support yet
	TLS EtcdTLS `mapstructure:"tls"`
}

type EtcdTLS

type EtcdTLS struct {
	Cert   string `mapstructure:"cert"`
	Key    string `mapstructure:"key"`
	Verify *bool  `mapstructure:"verify"`
	SNI    string `mapstructure:"sni"`
}

type Events

type Events struct {
	Module string `mapstructure:"module"`
}

type ExtPlugin

type ExtPlugin struct {
	Cmd []string `mapstructure:"cmd"`
}

type GraphQL

type GraphQL struct {
	MaxSize int `mapstructure:"max_size"`
}

type LRU

type LRU struct {
	Secret LRUCache `mapstructure:"secret"`
}

type LRUCache

type LRUCache struct {
	TTL      int `mapstructure:"ttl"`
	Count    int `mapstructure:"count"`
	NegTTL   int `mapstructure:"neg_ttl"`
	NegCount int `mapstructure:"neg_count"`
}

type Listen

type Listen struct {
	Ip          string `mapstructure:"ip"`
	Port        int    `mapstructure:"port"`
	EnableHttp2 bool   `mapstructure:"enable_http2"`
	EnableQuic  bool   `mapstructure:"enable_quic"`
	EnableHttp3 bool   `mapstructure:"enable_http3"`
}

type NginxConfig

type NginxConfig struct {
	ErrorLog                               string        `mapstructure:"error_log"`
	ErrorLogLevel                          string        `mapstructure:"error_log_level"`
	WorkerProcesses                        string        `mapstructure:"worker_processes"`
	EnableCPUAffinity                      bool          `mapstructure:"enable_cpu_affinity"`
	WorkerRlimitNofile                     int           `mapstructure:"worker_rlimit_nofile"`
	WorkerShutdownTimeout                  time.Duration `mapstructure:"worker_shutdown_timeout"`
	MaxPendingTimers                       int           `mapstructure:"max_pending_timers"`
	MaxRunningTimers                       int           `mapstructure:"max_running_timers"`
	Event                                  NginxEvent    `mapstructure:"event"`
	Meta                                   NginxMeta     `mapstructure:"meta"`
	Stream                                 NginxStream   `mapstructure:"stream"`
	MainConfigurationSnippet               string        `mapstructure:"main_configuration_snippet"`
	HTTPConfigurationSnippet               string        `mapstructure:"http_configuration_snippet"`
	HTTPServerConfigurationSnippet         string        `mapstructure:"http_server_configuration_snippet"`
	HTTPServerLocationConfigurationSnippet string        `mapstructure:"http_server_location_configuration_snippet"`
	HTTPAdminConfigurationSnippet          string        `mapstructure:"http_admin_configuration_snippet"`
	HTTPEndConfigurationSnippet            string        `mapstructure:"http_end_configuration_snippet"`
	StreamConfigurationSnippet             string        `mapstructure:"stream_configuration_snippet"`
	HTTP                                   NginxHTTP     `mapstructure:"http"`
}

type NginxEvent

type NginxEvent struct {
	WorkerConnections int `mapstructure:"worker_connections"`
}

type NginxHTTP

type NginxHTTP struct {
	EnableAccessLog       bool              `mapstructure:"enable_access_log"`
	AccessLog             string            `mapstructure:"access_log"`
	AccessLogBuffer       int               `mapstructure:"access_log_buffer"`
	AccessLogFormat       string            `mapstructure:"access_log_format"`
	AccessLogFormatEscape string            `mapstructure:"access_log_format_escape"`
	KeepaliveTimeout      time.Duration     `mapstructure:"keepalive_timeout"`
	ClientHeaderTimeout   time.Duration     `mapstructure:"client_header_timeout"`
	ClientBodyTimeout     time.Duration     `mapstructure:"client_body_timeout"`
	ClientMaxBodySize     int64             `mapstructure:"client_max_body_size"`
	SendTimeout           time.Duration     `mapstructure:"send_timeout"`
	UnderscoresInHeaders  string            `mapstructure:"underscores_in_headers"`
	RealIPHeader          string            `mapstructure:"real_ip_header"`
	RealIPRecursive       string            `mapstructure:"real_ip_recursive"`
	RealIPFrom            []string          `mapstructure:"real_ip_from"`
	ProxySSLServerName    bool              `mapstructure:"proxy_ssl_server_name"`
	Upstream              NginxUpstream     `mapstructure:"upstream"`
	Charset               string            `mapstructure:"charset"`
	VariablesHashMaxSize  int               `mapstructure:"variables_hash_max_size"`
	LuaSharedDict         map[string]string `mapstructure:"lua_shared_dict"`
	CustomLuaSharedDict   map[string]string `mapstructure:"custom_lua_shared_dict"`
	IPCSharedDict         map[string]string `mapstructure:"ipc_shared_dict"`
}

type NginxMeta

type NginxMeta struct {
	LuaSharedDict map[string]string `mapstructure:"lua_shared_dict"`
}

type NginxStream

type NginxStream struct {
	EnableAccessLog       bool              `mapstructure:"enable_access_log"`
	AccessLog             string            `mapstructure:"access_log"`
	AccessLogFormat       string            `mapstructure:"access_log_format"`
	AccessLogFormatEscape string            `mapstructure:"access_log_format_escape"`
	LuaSharedDict         map[string]string `mapstructure:"lua_shared_dict"`
}

type NginxUpstream

type NginxUpstream struct {
	Keepalive         int           `mapstructure:"keepalive"`
	KeepaliveRequests int           `mapstructure:"keepalive_requests"`
	KeepaliveTimeout  time.Duration `mapstructure:"keepalive_timeout"`
}

type NodeListen

type NodeListen struct {
	Ip                      string `mapstructure:"ip"`
	Port                    int    `mapstructure:"port"`
	EnableHttp2             bool   `mapstructure:"enable_http2"`
	ProxyProtocol           bool   `mapstructure:"proxy_protocol"`
	ProxyProtocolToUpstream bool   `mapstructure:"proxy_protocol_to_upstream"`
}

type PluginAttr

type PluginAttr map[string]any

type Proxy

type Proxy struct {
	// keepalive_timeout: 60s
	// client_header_timeout: 60s
	DialerTimeout   int `mapstructure:"dialer_timeout"`
	DialerKeepAlive int `mapstructure:"dialer_keep_alive"`

	IdleConnTimeout       int `mapstructure:"idle_conn_timeout"`
	TLSHandshakeTimeout   int `mapstructure:"tls_handshake_timeout"`
	ExpectContinueTimeout int `mapstructure:"expect_continue_timeout"`
	ResponseHeaderTimeout int `mapstructure:"response_header_timeout"`
	MaxIdleConns          int `mapstructure:"max_idle_conns"`
	MaxIdleConnsPerHost   int `mapstructure:"max_idle_conns_per_host"`
	MaxConnsPerHost       int `mapstructure:"max_conns_per_host"`
	MaxInFlight           int `mapstructure:"max_in_flight"`
}

section: proxy

type ProxyCache

type ProxyCache struct {
	CacheTtl time.Duration `mapstructure:"cache_ttl"`
	Zones    []Zone        `mapstructure:"zones"`
}

type ProxyProtocol

type ProxyProtocol struct {
	ListenHTTPPort        int  `mapstructure:"listen_http_port"`
	ListenHTTPSPort       int  `mapstructure:"listen_https_port"`
	EnableTCPPP           bool `mapstructure:"enable_tcp_pp"`
	EnableTCPPPToUpstream bool `mapstructure:"enable_tcp_pp_to_upstream"`
}

type RoleConfig

type RoleConfig struct {
	ConfigProvider string `mapstructure:"config_provider"`
}

type RoleTraditionalConfig

type RoleTraditionalConfig struct {
	ConfigProvider string `mapstructure:"config_provider"`
}

type Router

type Router struct {
	Http string `mapstructure:"http"`
	Ssl  string `mapstructure:"ssl"`
}

type Ssl

type Ssl struct {
	Enable                bool     `mapstructure:"enable"`
	Listen                []Listen `mapstructure:"listen"`
	SslTrustedCertificate string   `mapstructure:"ssl_trusted_certificate"`
	SslProtocols          string   `mapstructure:"ssl_protocols"`
	SslCiphers            string   `mapstructure:"ssl_ciphers"`
	SslSessionTickets     bool     `mapstructure:"ssl_session_tickets"`
	FallbackSNI           string   `mapstructure:"fallback_sni"`
}

type StandaloneFileWatcher

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

StandaloneFileWatcher loads the APISIX file-driven configuration and emits store events for added, updated, and removed resources.

func NewStandaloneFileWatcher

func NewStandaloneFileWatcher(path, provider string, events chan *store.Event) *StandaloneFileWatcher

func (*StandaloneFileWatcher) Reload

func (w *StandaloneFileWatcher) Reload() error

func (*StandaloneFileWatcher) ReloadSnapshot

func (w *StandaloneFileWatcher) ReloadSnapshot() (StandaloneReloadResult, error)

ReloadSnapshot emits the complete resource diff before returning its result.

func (*StandaloneFileWatcher) SeedCurrentSnapshot

func (w *StandaloneFileWatcher) SeedCurrentSnapshot(snapshot map[string]map[string][]byte)

SeedCurrentSnapshot sets the last-good standalone baseline. All map and byte slices are cloned so callers can safely reuse or mutate their input.

func (*StandaloneFileWatcher) SetAcknowledgedReloadCallback

func (w *StandaloneFileWatcher) SetAcknowledgedReloadCallback(
	callback func(StandaloneReloadResult, error) error,
)

SetAcknowledgedReloadCallback installs a serialized apply callback. A non-nil callback error keeps the previous snapshot so the next file event replays the complete diff.

func (*StandaloneFileWatcher) SetReloadCallback

func (w *StandaloneFileWatcher) SetReloadCallback(callback func(StandaloneReloadResult, error))

func (*StandaloneFileWatcher) Start

func (w *StandaloneFileWatcher) Start() error

Start registers the standalone file watcher. It is safe to call more than once; only the first call acquires filesystem resources.

func (*StandaloneFileWatcher) Stop

func (w *StandaloneFileWatcher) Stop() error

Stop cancels and joins the file watcher. It never closes the shared Store event channel and is safe before Start or when called repeatedly.

func (*StandaloneFileWatcher) Watch

func (w *StandaloneFileWatcher) Watch()

Watch preserves the historical logging-only API while Start exposes setup errors to lifecycle owners such as Server.

type StandaloneReloadResult

type StandaloneReloadResult struct {
	ChangedHTTPRouteBuckets []string
	ChangedStreamBuckets    []string
}

StandaloneReloadResult describes the route-relevant resources changed by one successfully applied standalone snapshot.

func (StandaloneReloadResult) AffectsHTTPRoutes

func (r StandaloneReloadResult) AffectsHTTPRoutes() bool

func (StandaloneReloadResult) AffectsStreams

func (r StandaloneReloadResult) AffectsStreams() bool

type Status

type Status struct {
	IP   string `mapstructure:"ip"`
	Port int    `mapstructure:"port"`
}

type StreamProxy

type StreamProxy struct {
	Tcp []TcpListen `mapstructure:"tcp"`
	Udp []string    `mapstructure:"udp"`
}

type TcpListen

type TcpListen struct {
	Addr                    string `mapstructure:"addr"`
	Tls                     bool   `mapstructure:"tls"`
	ProxyProtocol           bool   `mapstructure:"proxy_protocol"`
	ProxyProtocolToUpstream bool   `mapstructure:"proxy_protocol_to_upstream"`
}

type Wasm

type Wasm struct {
	Plugins []WasmPlugin `mapstructure:"plugins"`
}

type WasmPlugin

type WasmPlugin struct {
	Name     string `mapstructure:"name"`
	Priority int    `mapstructure:"priority"`
	File     string `mapstructure:"file"`
}

type XRPC

type XRPC struct {
	Protocols []XRPCProtocol `mapstructure:"protocols"`
}

type XRPCProtocol

type XRPCProtocol struct {
	Name string `mapstructure:"name"`
}

type Zone

type Zone struct {
	Name        string `mapstructure:"name"`
	MemorySize  string `mapstructure:"memory_size"`
	DiskSize    string `mapstructure:"disk_size"`
	DiskPath    string `mapstructure:"disk_path"`
	CacheLevels string `mapstructure:"cache_levels"`
}

Jump to

Keyboard shortcuts

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