config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config *configModel
)

Functions

func GetAuthConfig

func GetAuthConfig() authConfig

GetAuthConfig 获取认证配置

func GetConsoleURL added in v1.3.0

func GetConsoleURL() string

GetConsoleURL 返回控制台(前端)的访问地址,去掉末尾的斜杠;未配置时返回空字符串。 GetConsoleURL returns the console (frontend) address without a trailing slash; empty when not configured.

func GetDatabaseLegacyTimezone added in v1.2.0

func GetDatabaseLegacyTimezone() string

GetDatabaseLegacyTimezone 返回历史数据写入时区(仅用于 UTC 迁移)/ legacy write timezone used only for the UTC migration.

func GetDatabaseType

func GetDatabaseType() string

GetDatabaseType 获取数据库类型

func GetDisplayTimezone added in v1.2.0

func GetDisplayTimezone() string

GetDisplayTimezone 获取系统默认展示时区 / GetDisplayTimezone returns the system display timezone.

func GetExternalURL

func GetExternalURL() string

GetExternalURL 获取外部访问 URL GetExternalURL returns the external URL for accessing the Control Plane

func GetGRPCPort

func GetGRPCPort() int

GetGRPCPort 获取 gRPC 端口 GetGRPCPort returns the gRPC server port

func GetMaxPackageSize

func GetMaxPackageSize() int64

GetMaxPackageSize 获取最大安装包大小(字节)

func GetPackagesDir

func GetPackagesDir() string

GetPackagesDir 获取安装包存储目录

func GetPluginsDir

func GetPluginsDir() string

GetPluginsDir 获取插件存储目录

func GetSQLitePath

func GetSQLitePath() string

GetSQLitePath 获取 SQLite 文件路径

func GetTempDir

func GetTempDir() string

GetTempDir 获取临时文件目录

func IsGRPCEnabled

func IsGRPCEnabled() bool

IsGRPCEnabled 检查 gRPC 是否启用 IsGRPCEnabled checks if gRPC server is enabled

func ServerConfigError

func ServerConfigError() error

ServerConfigError 返回服务端配置加载或校验错误,CLI 本地命令不受该错误影响。 ServerConfigError returns the server configuration loading or validation error without blocking local CLI commands.

Types

type AppConfig

type AppConfig struct {
	AppName           string `mapstructure:"app_name"`
	Env               string `mapstructure:"env"`
	Addr              string `mapstructure:"addr"`
	APIPrefix         string `mapstructure:"api_prefix"`
	SessionCookieName string `mapstructure:"session_cookie_name"`
	SessionSecret     string `mapstructure:"session_secret"`
	SessionDomain     string `mapstructure:"session_domain"`
	SessionAge        int    `mapstructure:"session_age"`
	SessionHttpOnly   bool   `mapstructure:"session_http_only"`
	SessionSecure     bool   `mapstructure:"session_secure"`

	// ExternalURL is the external URL for accessing the Control Plane.
	// ExternalURL 是访问 Control Plane 的外部 URL。
	// This is used for generating Agent install commands and other external references.
	// 用于生成 Agent 安装命令和其他外部引用。
	// Example: "http://192.168.1.100:17800" or "https://stx.example.com"
	// 示例: "http://192.168.1.100:17800" 或 "https://stx.example.com"
	ExternalURL string `mapstructure:"external_url"`
	// ConsoleURL 是用户在浏览器里打开控制台的地址(前端),告警通知里的作业链接用它拼;为空时通知不带链接。
	// ConsoleURL is the address users open the console (frontend) at; job links in alert notifications are built
	// from it, and notifications carry no link when it is empty.
	ConsoleURL string `mapstructure:"console_url"`

	// DisplayTimezone 系统默认展示时区(IANA 名称,默认 Asia/Shanghai);用于报告渲染、默认 cron 时区与前端默认展示。
	// 数据库存储始终为 UTC,与此配置无关。环境变量 STX_DISPLAY_TIMEZONE(兼容 STX_REPORT_TIMEZONE)可覆盖。
	// DisplayTimezone is the system default display timezone (IANA, default Asia/Shanghai) used for reports,
	// default cron timezone and frontend default display. Storage is always UTC regardless of this setting.
	DisplayTimezone string `mapstructure:"display_timezone"`
}

AppConfig 应用基本配置(导出供其他包使用) AppConfig holds basic application configuration (exported for other packages)

type DatabaseConfig

type DatabaseConfig struct {
	Enabled         bool   `mapstructure:"enabled"`
	Type            string `mapstructure:"type"`        // sqlite, mysql, postgres
	SQLitePath      string `mapstructure:"sqlite_path"` // SQLite 文件路径
	Host            string `mapstructure:"host"`
	Port            int    `mapstructure:"port"`
	Username        string `mapstructure:"username"`
	Password        string `mapstructure:"password"`
	Database        string `mapstructure:"database"`
	MaxIdleConn     int    `mapstructure:"max_idle_conn"`
	MaxOpenConn     int    `mapstructure:"max_open_conn"`
	ConnMaxLifetime int    `mapstructure:"conn_max_lifetime"`
	// LegacyTimezone 升级前 MySQL DATETIME 列写入时使用的时区(旧 DSN 为 loc=Local),用于一次性迁移到 UTC;
	// 为空时使用当前进程 time.Local。SQLite 自带偏移、PostgreSQL 为 timestamptz,均无需此项。
	// LegacyTimezone is the zone legacy MySQL DATETIME values were written in (old DSN used loc=Local), used once to
	// migrate them to UTC; empty means the process time.Local. SQLite stores offsets and PostgreSQL uses timestamptz.
	LegacyTimezone string `mapstructure:"legacy_timezone"`
	LogLevel       string `mapstructure:"log_level"`
}

DatabaseConfig 数据库配置(导出供其他包使用)

type GRPCConfig

type GRPCConfig struct {
	// Enabled indicates whether gRPC server is enabled
	// Enabled 表示是否启用 gRPC 服务器
	Enabled bool `mapstructure:"enabled"`

	// Port is the port number for the gRPC server (default: 17890)
	// Port 是 gRPC 服务器的端口号(默认:17890)
	Port int `mapstructure:"port"`

	// TLSEnabled indicates whether TLS is enabled
	// TLSEnabled 表示是否启用 TLS
	TLSEnabled bool `mapstructure:"tls_enabled"`

	// CertFile is the path to the TLS certificate file
	// CertFile 是 TLS 证书文件的路径
	CertFile string `mapstructure:"cert_file"`

	// KeyFile is the path to the TLS key file
	// KeyFile 是 TLS 密钥文件的路径
	KeyFile string `mapstructure:"key_file"`

	// CAFile is the path to the CA certificate file for client verification
	// CAFile 是用于客户端验证的 CA 证书文件路径
	CAFile string `mapstructure:"ca_file"`

	// MaxRecvMsgSize is the maximum receive message size in MB (default: 16)
	// MaxRecvMsgSize 是最大接收消息大小(MB,默认:16)
	MaxRecvMsgSize int `mapstructure:"max_recv_msg_size"`

	// MaxSendMsgSize is the maximum send message size in MB (default: 16)
	// MaxSendMsgSize 是最大发送消息大小(MB,默认:16)
	MaxSendMsgSize int `mapstructure:"max_send_msg_size"`

	// HeartbeatInterval is the heartbeat interval to send to Agents (seconds, default: 10)
	// HeartbeatInterval 是发送给 Agent 的心跳间隔(秒,默认:10)
	HeartbeatInterval int `mapstructure:"heartbeat_interval"`

	// HeartbeatTimeout is the timeout for considering an Agent offline (seconds, default: 30)
	// HeartbeatTimeout 是判断 Agent 离线的超时时间(秒,默认:30)
	HeartbeatTimeout int `mapstructure:"heartbeat_timeout"`
}

GRPCConfig gRPC 服务器配置 GRPCConfig holds configuration for the gRPC server

func GetGRPCConfig

func GetGRPCConfig() GRPCConfig

GetGRPCConfig 获取 gRPC 配置 GetGRPCConfig returns the gRPC configuration

type OAuth2Config

type OAuth2Config struct {
	ClientID              string `mapstructure:"client_id"`
	ClientSecret          string `mapstructure:"client_secret"`
	RedirectURI           string `mapstructure:"redirect_uri"`
	AuthorizationEndpoint string `mapstructure:"authorization_endpoint"`
	TokenEndpoint         string `mapstructure:"token_endpoint"`
	UserEndpoint          string `mapstructure:"user_endpoint"`
}

OAuth2Config OAuth2认证配置(保留用于兼容旧配置)

type OAuthProviderConfig

type OAuthProviderConfig struct {
	Enabled      bool   `mapstructure:"enabled"`
	ClientID     string `mapstructure:"client_id"`
	ClientSecret string `mapstructure:"client_secret"`
	RedirectURI  string `mapstructure:"redirect_uri"`
}

OAuthProviderConfig 单个 OAuth 提供商配置

type OAuthProvidersConfig

type OAuthProvidersConfig struct {
	GitHub OAuthProviderConfig `mapstructure:"github"`
	Google OAuthProviderConfig `mapstructure:"google"`
}

OAuthProvidersConfig 多 OAuth 提供商配置

type ObservabilityAlertmanagerConfig

type ObservabilityAlertmanagerConfig struct {
	URL string `mapstructure:"url"`

	// WebhookPath is the fixed Alertmanager webhook path exposed by STX.
	// WebhookPath 是 STX 暴露的 Alertmanager Webhook 路径。
	WebhookPath string `mapstructure:"webhook_path"`
}

ObservabilityAlertmanagerConfig Alertmanager 集成配置

type ObservabilityConfig

type ObservabilityConfig struct {
	// Enabled indicates whether observability integration is enabled.
	// Enabled 表示是否启用可观测性集成。
	Enabled bool `mapstructure:"enabled"`

	Prometheus      ObservabilityPrometheusConfig      `mapstructure:"prometheus"`
	Alertmanager    ObservabilityAlertmanagerConfig    `mapstructure:"alertmanager"`
	Grafana         ObservabilityGrafanaConfig         `mapstructure:"grafana"`
	SeatunnelMetric ObservabilitySeatunnelMetricConfig `mapstructure:"seatunnel_metrics"`
}

ObservabilityConfig 可观测性配置(Prometheus/Grafana/Alertmanager 集成)

type ObservabilityGrafanaConfig

type ObservabilityGrafanaConfig struct {
	URL string `mapstructure:"url"`
}

ObservabilityGrafanaConfig Grafana 集成配置

type ObservabilityPrometheusConfig

type ObservabilityPrometheusConfig struct {
	URL string `mapstructure:"url"`

	// HTTPSDPath is the fixed HTTP SD endpoint path exposed by STX.
	// HTTPSDPath 是 STX 暴露的 Prometheus HTTP SD 路径。
	HTTPSDPath string `mapstructure:"http_sd_path"`
}

ObservabilityPrometheusConfig Prometheus 集成配置

type ObservabilitySeatunnelMetricConfig

type ObservabilitySeatunnelMetricConfig struct {
	Path string `mapstructure:"path"`

	// ProbeTimeoutSeconds is the timeout for probing one metrics endpoint.
	// ProbeTimeoutSeconds 是单个 metrics 端点探测超时时间(秒)。
	ProbeTimeoutSeconds int `mapstructure:"probe_timeout_seconds"`
}

ObservabilitySeatunnelMetricConfig SeaTunnel metrics 探测配置

type StorageConfig

type StorageConfig struct {
	// BaseDir 基础存储目录,其他目录默认相对于此目录
	// BaseDir is the base storage directory, other directories are relative to this
	BaseDir string `mapstructure:"base_dir"`

	// PackagesDir SeaTunnel 安装包存储目录
	// PackagesDir is the directory for SeaTunnel installation packages
	PackagesDir string `mapstructure:"packages_dir"`

	// PluginsDir 插件包存储目录(connector jars, lib dependencies)
	// PluginsDir is the directory for plugin packages
	PluginsDir string `mapstructure:"plugins_dir"`

	// TempDir 临时文件目录(下载中的文件等)
	// TempDir is the directory for temporary files
	TempDir string `mapstructure:"temp_dir"`

	// MaxPackageSize 最大安装包大小(MB),默认 2048MB (2GB)
	// MaxPackageSize is the maximum package size in MB
	MaxPackageSize int64 `mapstructure:"max_package_size"`

	// CleanupIntervalHours 临时文件清理间隔(小时),默认 24
	// CleanupIntervalHours is the interval for cleaning up temp files
	CleanupIntervalHours int `mapstructure:"cleanup_interval_hours"`
}

StorageConfig 存储配置(本地文件存储目录)

func GetStorageConfig

func GetStorageConfig() StorageConfig

GetStorageConfig 获取存储配置

type SyncConfig

type SyncConfig struct {
	// PreviewDataTTLMinutes controls how long preview session data is retained.
	// PreviewDataTTLMinutes 控制预览会话数据的保留时长(分钟)。
	PreviewDataTTLMinutes int `mapstructure:"preview_data_ttl_minutes"`
	// PreviewDataTTLHours is kept for backward compatibility and will be used when minute-level config is absent.
	// PreviewDataTTLHours 仅用于兼容旧配置;未设置分钟级配置时才会使用。
	PreviewDataTTLHours int `mapstructure:"preview_data_ttl_hours"`
	// JobReconcilerIntervalSeconds 对账 tick 间隔;0 表示默认 10 秒,小于 0 表示关闭对账器。
	// JobReconcilerIntervalSeconds is the reconciler tick interval; 0 means default 10s, negative disables it.
	JobReconcilerIntervalSeconds int `mapstructure:"job_reconciler_interval_seconds"`
	// JobReconcilerEventModeIntervalSeconds 是事件通道健康时完整对账(拉 running/finished 列表)的最长间隔;默认 0 表示关闭自适应,配置正数才开启。
	// JobReconcilerEventModeIntervalSeconds is the longest interval between full reconciles (running/finished lists)
	// while the event channel is healthy; the default 0 disables adaptive polling, a positive value enables it.
	JobReconcilerEventModeIntervalSeconds int `mapstructure:"job_reconciler_event_mode_interval_seconds"`
	// SubmitTimeoutSeconds 是提交结果未知时等待引擎出现作业的上限;0 或不填表示默认 300 秒,任务可单独覆盖。
	// SubmitTimeoutSeconds caps how long an unknown submit waits for the engine to register the job; 0 or unset
	// means the 300-second default, and tasks may override it.
	SubmitTimeoutSeconds int `mapstructure:"submit_timeout_seconds"`
	// StopTimeoutSeconds 是停止请求发出后等待作业真正停下的上限,超过只标记停止超时;0 或不填表示默认 300 秒。
	// StopTimeoutSeconds caps how long a stop request waits for the job to actually stop before it is flagged as
	// overdue; 0 or unset means the 300-second default.
	StopTimeoutSeconds int `mapstructure:"stop_timeout_seconds"`
	// JobReconcilerClusterConcurrency 是同时对账的集群数上限;0 或不填表示默认 4。
	// JobReconcilerClusterConcurrency caps how many clusters reconcile at the same time; 0 or unset means 4.
	JobReconcilerClusterConcurrency int `mapstructure:"job_reconciler_cluster_concurrency"`
	// JobReconcilerMaxBackoffSeconds 是集群查询连续失败后推迟对账的上限;0 或不填表示默认 120 秒。
	// JobReconcilerMaxBackoffSeconds caps how long a cluster's reconcile is pushed back after repeated query
	// failures; 0 or unset means 120 seconds.
	JobReconcilerMaxBackoffSeconds int `mapstructure:"job_reconciler_max_backoff_seconds"`
	// EngineRequestTimeoutSeconds 是请求 SeaTunnel REST 接口的 HTTP 超时,读写请求共用;0 或不填表示默认 15 秒。
	// EngineRequestTimeoutSeconds is the HTTP timeout for SeaTunnel REST calls, shared by reads and writes; 0 or
	// unset means 15 seconds.
	EngineRequestTimeoutSeconds int `mapstructure:"engine_request_timeout_seconds"`
}

SyncConfig 同步工作台相关配置。 SyncConfig holds sync studio related settings.

type TelemetryConfig

type TelemetryConfig struct {
	// Enabled indicates whether OpenTelemetry tracing is enabled
	// Enabled 表示是否启用 OpenTelemetry 追踪
	Enabled bool `mapstructure:"enabled"`

	// Endpoint is the OTLP collector endpoint (default: localhost:4317)
	// Endpoint 是 OTLP 收集器端点(默认:localhost:4317)
	Endpoint string `mapstructure:"endpoint"`
}

TelemetryConfig 遥测配置 TelemetryConfig holds telemetry/tracing configuration

Jump to

Keyboard shortcuts

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