Documentation
¶
Overview ¶
Package app defines global configuration models and config loading helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
Driver string `json:"driver"` // Cache driver name.
Prefix string `json:"prefix"` // Cache key prefix.
}
Cache holds global cache settings.
type Collector ¶
type Collector struct {
MonitorSelf bool `json:"monitor_self"` // Whether to monitor this service container itself.
UnstructuredLogLineFlags []string `json:"unstructured_log_line_flags"` // Prefix flags recognized as unstructured logs.
TimeLayout []string `json:"time_layout"` // Supported log time formats.
ContainerName []string `json:"container_name"` // Container names to collect logs from.
}
Collector controls Docker log collection behavior.
type Config ¶
type Config struct {
System SysConfig `json:"system"` // Application runtime settings.
Log LogConfig `json:"log"` // Logger output settings.
Databases []Databases `json:"databases"` // Database connection settings.
Cache Cache `json:"cache"` // Cache settings.
Redis []Redis `json:"redis"` // Redis client settings.
Monitor Monitor `json:"monitor"` // Panic and alert monitor settings.
Feishu Feishu `json:"feishu"` // Feishu integration settings.
Collector Collector `json:"collector"` // Docker log collector settings.
}
Config is the root configuration model loaded from bin/configs/*.json.
func GetConfig ¶
func GetConfig() *Config
GetConfig returns the globally loaded configuration singleton.
Returns:
- *Config: configuration instance loaded by LoadConfig.
func LoadConfig ¶
LoadConfig loads configuration from bin/configs/<RUN_ENV>.json.
Returns:
- *Config: parsed configuration instance also stored globally.
- error: returned when reading or decoding configuration fails.
Behavior:
- Uses "local" when RUN_ENV is not provided.
- Applies APP_NAME override when present.
Example:
cfg, err := app.LoadConfig()
if err != nil {
panic(err)
}
type Databases ¶
type Databases struct {
Enable bool `json:"enable"` // Whether this DB profile is enabled.
DbType string `json:"db_type"` // Database type, such as mysql.
DbHost string `json:"db_host"` // Database host.
DbName string `json:"db_name"` // Database name.
DbUsername string `json:"db_username,omitempty"` // Database username.
DbPassword string `json:"db_password,omitempty"` // Database password.
DbMaxIdleConn int `json:"db_max_idle_conn,omitempty"` // Maximum idle connections.
DbMaxOpenConn int `json:"db_max_open_conn,omitempty"` // Maximum open connections.
DbMaxLifetime time.Duration `json:"db_max_lifetime,omitempty"` // Connection max lifetime in hours.
DbConnectRetryCount int `json:"db_connect_retry_count,omitempty"` // Retry count when DB initialization fails.
DbConnectRetryInterval int `json:"db_connect_retry_interval,omitempty"` // Retry interval in seconds.
}
Databases stores one database connection profile.
type LogConfig ¶
type LogConfig struct {
Driver string `json:"driver"` // Logger driver, such as "stdout" or "file".
Level string `json:"level"` // Log level: debug, info, warn, error, fatal.
LogPath string `json:"path"` // Log file path when driver is "file".
}
LogConfig controls logger driver and severity level.
type Monitor ¶
type Monitor struct {
PanicRobot PanicRobot `json:"panic_robot"`
}
type PanicRobot ¶
type PanicRobot struct {
Enable bool `json:"enable"`
Wechat robotConfig `json:"wechat"`
Feishu robotConfig `json:"feishu"`
}
type Redis ¶
type Redis struct {
Name string `json:"name"` // Redis connection alias.
Enable bool `json:"enable"` // Whether this Redis profile is enabled.
Host string `json:"host"` // Redis host.
Auth string `json:"auth"` // Redis password or auth token.
MaxIdle int `json:"max_idle"` // Maximum idle connections.
MaxActive int `json:"max_active"` // Maximum active connections.
IdleTimeout time.Duration `json:"idle_timeout"` // Idle timeout in minutes.
Prefix string `json:"prefix"` // Redis key prefix.
DB int `json:"db"`
}
Redis stores one Redis connection profile.
type SysConfig ¶
type SysConfig struct {
Name string `json:"name"` // Service name.
RunMode string `json:"run_mode"` // Gin run mode.
HTTPPort string `json:"http_port"` // HTTP listen address.
ReadTimeout time.Duration `json:"read_timeout"` // Maximum request read timeout in seconds.
WriteTimeout time.Duration `json:"write_timeout"` // Maximum response write timeout in seconds.
Version string `json:"version"` // Service version.
RootPath string `json:"root_path"` // Runtime root path.
DebugMode bool `json:"debug_mode"` // Debug mode toggle.
LangDir string `json:"lang_dir"` // i18n language files directory.
DefaultLang string `json:"default_lang"` // Default language key.
EnvKey string `json:"env_key"` // Environment variable key that stores run env.
JwtSecret string `json:"jwt_secret"` // Secret key for JWT signing.
TokenExpire time.Duration `json:"token_expire"` // JWT expiration time in seconds.
Env string `json:"env"` // Resolved runtime environment.
}
SysConfig stores basic runtime properties for the service.
Directories
¶
| Path | Synopsis |
|---|---|
|
http
|
|
|
controller/auth
Package auth provides HTTP handlers for server app authentication endpoints.
|
Package auth provides HTTP handlers for server app authentication endpoints. |
|
middleware
Package middleware provides shared Gin middleware used by dockmon APIs.
|
Package middleware provides shared Gin middleware used by dockmon APIs. |
|
router
Package router wires HTTP route groups and registers controller handlers.
|
Package router wires HTTP route groups and registers controller handlers. |
|
Package job registers scheduled background jobs.
|
Package job registers scheduled background jobs. |
|
monitor
Package monitor implements scheduled job handlers under the job domain.
|
Package monitor implements scheduled job handlers under the job domain. |
|
model
|
|
|
auth
Package auth defines persistence models for authentication domain objects.
|
Package auth defines persistence models for authentication domain objects. |
|
collector
Package collector defines persistence models for collected container logs.
|
Package collector defines persistence models for collected container logs. |
|
Package monitor implements Docker log collection and parsing workflows.
|
Package monitor implements Docker log collection and parsing workflows. |
|
pkg
|
|
|
e
Package e defines business and HTTP error codes used in API responses.
|
Package e defines business and HTTP error codes used in API responses. |
|
jwt
Package jwt provides helpers for generating and parsing server app JWT tokens.
|
Package jwt provides helpers for generating and parsing server app JWT tokens. |
|
schedule
Package schedule provides a lightweight in-process scheduler with optional single-node locking via Redis.
|
Package schedule provides a lightweight in-process scheduler with optional single-node locking via Redis. |
|
trace
Package trace provides concurrent-safe trace ID generation utilities.
|
Package trace provides concurrent-safe trace ID generation utilities. |
|
repository
|
|
|
auth
Package auth implements auth-domain repository access methods.
|
Package auth implements auth-domain repository access methods. |
|
collector
Package collector implements collector-domain repository access methods.
|
Package collector implements collector-domain repository access methods. |
|
Package service defines service-layer contracts and compositions.
|
Package service defines service-layer contracts and compositions. |
|
collector
Package collector provides service-layer orchestration for collected logs.
|
Package collector provides service-layer orchestration for collected logs. |
Click to show internal directories.
Click to hide internal directories.