config

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentAddress

type AgentAddress struct {
	URL string `json:"url" mapstructure:"url"`
	Tag string `json:"tag" mapstructure:"tag"`
}

type AgentCacheConfig

type AgentCacheConfig struct {
	TokenCapacity           int `mapstructure:"token_capacity"`
	UserCapacity            int `mapstructure:"user_capacity"`
	UserRoutingsCapacity    int `mapstructure:"user_routings_capacity"`
	PrivateChannelsCapacity int `mapstructure:"private_channels_capacity"`
	NegativeTTLSeconds      int `mapstructure:"negative_ttl_seconds"`
}

AgentCacheConfig 控制 agent 端 LRU 缓存的容量与负缓存 TTL。

type AgentConfig

type AgentConfig struct {
	Listen              string           `mapstructure:"listen"`     // ":8139" | "unix:/run/gw.sock" | "unix:@name"(abstract, Linux)
	MasterURL           string           `mapstructure:"master_url"` // "http://host:port" | "unix:/run/gw.sock"(same-host UDS)
	EnrollmentToken     string           `mapstructure:"enrollment_token"`
	CredentialsFile     string           `mapstructure:"credentials_file"`
	FullSyncInterval    int              `mapstructure:"full_sync_interval"`
	ReportBufferSize    int              `mapstructure:"report_buffer_size"`
	ReportFlushInterval int              `mapstructure:"report_flush_interval"`
	HeartbeatInterval   int              `mapstructure:"heartbeat_interval"`
	HTTPAddresses       []AgentAddress   `mapstructure:"http_addresses"`
	Tags                string           `mapstructure:"tags"`
	ProxyURL            string           `mapstructure:"proxy_url"`
	PreferredAddrTag    string           `mapstructure:"preferred_address_tag"`
	Cache               AgentCacheConfig `mapstructure:"cache"`
}

type AgentRuntimeConfig

type AgentRuntimeConfig struct {
	LogLevel string
	Agent    AgentConfig
	Runtime  RuntimeConfig
	Relay    RelayConfig
}

func LoadAgent

func LoadAgent(path string) (*AgentRuntimeConfig, error)

func (*AgentRuntimeConfig) ToAgentRuntimeConfig

func (c *AgentRuntimeConfig) ToAgentRuntimeConfig() *AgentRuntimeConfig

type AgentRuntimeProvider

type AgentRuntimeProvider interface {
	ToAgentRuntimeConfig() *AgentRuntimeConfig
}

type Config

type Config struct {
	Role     string         `mapstructure:"role"`
	Listen   string         `mapstructure:"listen"` // ":8140" | "unix:/run/gw.sock" | "unix:@name"(abstract, Linux)
	LogLevel string         `mapstructure:"log_level"`
	Master   MasterConfig   `mapstructure:"master"`
	Agent    AgentConfig    `mapstructure:"agent"`
	Relay    RelayConfig    `mapstructure:"relay"`
	EventBus EventBusConfig `mapstructure:"eventbus"`
}

func Load

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

func (*Config) ToAgentRuntimeConfig

func (c *Config) ToAgentRuntimeConfig() *AgentRuntimeConfig

func (*Config) ToMasterRuntimeConfig

func (c *Config) ToMasterRuntimeConfig() *MasterRuntimeConfig

type EventBusConfig

type EventBusConfig struct {
	Type    string `mapstructure:"type"`
	NatsURL string `mapstructure:"nats_url"`
}

type FileConfig

type FileConfig struct {
	LogLevel string        `mapstructure:"log_level"`
	Master   MasterConfig  `mapstructure:"master"`
	Agent    AgentConfig   `mapstructure:"agent"`
	Runtime  RuntimeConfig `mapstructure:"runtime"`
	Relay    RelayConfig   `mapstructure:"relay"`
}

type MasterConfig

type MasterConfig struct {
	Listen             string   `mapstructure:"listen"` // ":8140" | "unix:/run/gw.sock" | "unix:@name"(abstract, Linux)
	DBPath             string   `mapstructure:"db_path"`
	JWTSecret          string   `mapstructure:"jwt_secret"`
	BYOKKEK            string   `mapstructure:"byok_kek"` // base64 32B; empty → HKDF derive from JWTSecret
	EnrollmentTokenTTL int      `mapstructure:"enrollment_token_ttl"`
	AdminUser          string   `mapstructure:"admin_user"`
	AdminPassword      string   `mapstructure:"admin_password"`
	ProxyURL           string   `mapstructure:"proxy_url"`
	PublicBaseURLs     []string `mapstructure:"public_base_urls"`
}

type MasterRuntimeConfig

type MasterRuntimeConfig struct {
	LogLevel string
	Master   MasterConfig
	Agent    AgentConfig
	Runtime  RuntimeConfig
	Relay    RelayConfig
}

func LoadMaster

func LoadMaster(path string) (*MasterRuntimeConfig, error)

func (*MasterRuntimeConfig) ToMasterRuntimeConfig

func (c *MasterRuntimeConfig) ToMasterRuntimeConfig() *MasterRuntimeConfig

type MasterRuntimeProvider

type MasterRuntimeProvider interface {
	ToMasterRuntimeConfig() *MasterRuntimeConfig
}

type RelayConfig

type RelayConfig struct {
	Timeout             int `mapstructure:"timeout"`
	MaxIdleConns        int `mapstructure:"max_idle_conns"`
	MaxIdleConnsPerHost int `mapstructure:"max_idle_conns_per_host"`
	KeepaliveIdle       int `mapstructure:"keepalive_idle"`
	KeepaliveInterval   int `mapstructure:"keepalive_interval"`
	KeepaliveCount      int `mapstructure:"keepalive_count"`
}

type RuntimeConfig

type RuntimeConfig struct {
	RelayTimeout        int `mapstructure:"relay_timeout"`
	FullSyncInterval    int `mapstructure:"full_sync_interval"`
	ReportBufferSize    int `mapstructure:"report_buffer_size"`
	ReportFlushInterval int `mapstructure:"report_flush_interval"`
	HeartbeatInterval   int `mapstructure:"heartbeat_interval"`
}

Jump to

Keyboard shortcuts

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