diff --git a/database/gredis/gredis_config.go b/database/gredis/gredis_config.go index 575008cae..b3427b38d 100644 --- a/database/gredis/gredis_config.go +++ b/database/gredis/gredis_config.go @@ -22,27 +22,27 @@ import ( type Config struct { // Address It supports single and cluster redis server. Multiple addresses joined with char ','. Eg: 192.168.1.1:6379, 192.168.1.2:6379. Address string `json:"address" v:"required" dc:"Redis server address|i18n:config.redis.address"` - Db int `json:"db" d:"0" dc:"Redis database index|i18n:config.redis.db"` // Redis db. - User string `json:"user" dc:"Username for AUTH|i18n:config.redis.user"` // Username for AUTH. - Pass string `json:"pass" dc:"Password for AUTH|i18n:config.redis.pass"` // Password for AUTH. - SentinelUser string `json:"sentinel_user" dc:"Username for sentinel AUTH|i18n:config.redis.sentinelUser"` // Username for sentinel AUTH. - SentinelPass string `json:"sentinel_pass" dc:"Password for sentinel AUTH|i18n:config.redis.sentinelPass"` // Password for sentinel AUTH. - MinIdle int `json:"minIdle" d:"0" dc:"Min idle connections|i18n:config.redis.minIdle"` // Minimum number of connections allowed to be idle (default is 0) - MaxIdle int `json:"maxIdle" d:"10" dc:"Max idle connections|i18n:config.redis.maxIdle"` // Maximum number of connections allowed to be idle (default is 10) - MaxActive int `json:"maxActive" d:"0" dc:"Max active connections (0=unlimited)|i18n:config.redis.maxActive"` // Maximum number of connections limit (default is 0 means no limit). - MaxConnLifetime time.Duration `json:"maxConnLifetime" d:"30s" dc:"Max connection lifetime|i18n:config.redis.maxConnLifetime"` // Maximum lifetime of the connection (default is 30 seconds, not allowed to be set to 0) - IdleTimeout time.Duration `json:"idleTimeout" d:"10s" dc:"Idle connection timeout|i18n:config.redis.idleTimeout"` // Maximum idle time for connection (default is 10 seconds, not allowed to be set to 0) - WaitTimeout time.Duration `json:"waitTimeout" dc:"Wait timeout for connection pool|i18n:config.redis.waitTimeout"` // Timed out duration waiting to get a connection from the connection pool. - DialTimeout time.Duration `json:"dialTimeout" dc:"Dial connection timeout|i18n:config.redis.dialTimeout"` // Dial connection timeout for TCP. - ReadTimeout time.Duration `json:"readTimeout" dc:"Read timeout|i18n:config.redis.readTimeout"` // Read timeout for TCP. DO NOT set it if not necessary. - WriteTimeout time.Duration `json:"writeTimeout" dc:"Write timeout|i18n:config.redis.writeTimeout"` // Write timeout for TCP. - MasterName string `json:"masterName" dc:"Master name for Sentinel mode|i18n:config.redis.masterName"` // Used in Redis Sentinel mode. - TLS bool `json:"tls" d:"false" dc:"Enable TLS connection|i18n:config.redis.tls"` // Specifies whether TLS should be used when connecting to the server. - TLSSkipVerify bool `json:"tlsSkipVerify" d:"false" dc:"Skip TLS server name verification|i18n:config.redis.tlsSkipVerify"` // Disables server name verification when connecting over TLS. - TLSConfig *tls.Config `json:"-"` // TLS Config to use. When set TLS will be negotiated. - SlaveOnly bool `json:"slaveOnly" d:"false" dc:"Route commands to slave nodes only|i18n:config.redis.slaveOnly"` // Route all commands to slave read-only nodes. - Cluster bool `json:"cluster" d:"false" dc:"Enable cluster mode|i18n:config.redis.cluster"` // Specifies whether cluster mode be used. - Protocol int `json:"protocol" d:"3" dc:"RESP protocol version (2 or 3)|i18n:config.redis.protocol"` // Specifies the RESP version (Protocol 2 or 3.) + Db int `json:"db" d:"0" dc:"Redis database index|i18n:config.redis.db"` // Redis db. + User string `json:"user" dc:"Username for AUTH|i18n:config.redis.user"` // Username for AUTH. + Pass string `json:"pass" dc:"Password for AUTH|i18n:config.redis.pass"` // Password for AUTH. + SentinelUser string `json:"sentinel_user" dc:"Username for sentinel AUTH|i18n:config.redis.sentinelUser"` // Username for sentinel AUTH. + SentinelPass string `json:"sentinel_pass" dc:"Password for sentinel AUTH|i18n:config.redis.sentinelPass"` // Password for sentinel AUTH. + MinIdle int `json:"minIdle" d:"0" dc:"Min idle connections|i18n:config.redis.minIdle"` // Minimum number of connections allowed to be idle (default is 0) + MaxIdle int `json:"maxIdle" d:"10" dc:"Max idle connections|i18n:config.redis.maxIdle"` // Maximum number of connections allowed to be idle (default is 10) + MaxActive int `json:"maxActive" d:"0" dc:"Max active connections (0=unlimited)|i18n:config.redis.maxActive"` // Maximum number of connections limit (default is 0 means no limit). + MaxConnLifetime time.Duration `json:"maxConnLifetime" d:"30s" dc:"Max connection lifetime|i18n:config.redis.maxConnLifetime"` // Maximum lifetime of the connection (default is 30 seconds, not allowed to be set to 0) + IdleTimeout time.Duration `json:"idleTimeout" d:"10s" dc:"Idle connection timeout|i18n:config.redis.idleTimeout"` // Maximum idle time for connection (default is 10 seconds, not allowed to be set to 0) + WaitTimeout time.Duration `json:"waitTimeout" dc:"Wait timeout for connection pool|i18n:config.redis.waitTimeout"` // Timed out duration waiting to get a connection from the connection pool. + DialTimeout time.Duration `json:"dialTimeout" dc:"Dial connection timeout|i18n:config.redis.dialTimeout"` // Dial connection timeout for TCP. + ReadTimeout time.Duration `json:"readTimeout" dc:"Read timeout|i18n:config.redis.readTimeout"` // Read timeout for TCP. DO NOT set it if not necessary. + WriteTimeout time.Duration `json:"writeTimeout" dc:"Write timeout|i18n:config.redis.writeTimeout"` // Write timeout for TCP. + MasterName string `json:"masterName" dc:"Master name for Sentinel mode|i18n:config.redis.masterName"` // Used in Redis Sentinel mode. + TLS bool `json:"tls" d:"false" dc:"Enable TLS connection|i18n:config.redis.tls"` // Specifies whether TLS should be used when connecting to the server. + TLSSkipVerify bool `json:"tlsSkipVerify" d:"false" dc:"Skip TLS server name verification|i18n:config.redis.tlsSkipVerify"` // Disables server name verification when connecting over TLS. + TLSConfig *tls.Config `json:"-"` // TLS Config to use. When set TLS will be negotiated. + SlaveOnly bool `json:"slaveOnly" d:"false" dc:"Route commands to slave nodes only|i18n:config.redis.slaveOnly"` // Route all commands to slave read-only nodes. + Cluster bool `json:"cluster" d:"false" dc:"Enable cluster mode|i18n:config.redis.cluster"` // Specifies whether cluster mode be used. + Protocol int `json:"protocol" d:"3" dc:"RESP protocol version (2 or 3)|i18n:config.redis.protocol"` // Specifies the RESP version (Protocol 2 or 3.) } const ( diff --git a/os/gcfg/gcfg_schema.go b/os/gcfg/gcfg_schema.go index 3d1311287..8ddf731e4 100644 --- a/os/gcfg/gcfg_schema.go +++ b/os/gcfg/gcfg_schema.go @@ -18,14 +18,14 @@ import ( // extracted from struct tags (json, d, v, dc) via reflection. type FieldSchema struct { Name string `json:"name"` // Go struct field name - JsonKey string `json:"jsonKey"` // JSON/YAML key from json tag - Type string `json:"type"` // Field type: string, int, bool, duration, etc. - Default string `json:"default"` // Default value from `d` tag - Rule string `json:"rule"` // Validation rule from `v` tag - Description string `json:"description"` // English description from `dc` tag - I18nKey string `json:"i18nKey"` // I18n key extracted from `dc` tag (i18n:xxx) - Group string `json:"group"` // Logical group (Basic, Logging, Cookie, etc.) - Options []string `json:"options,omitempty"` // Enum options if applicable + JsonKey string `json:"jsonKey"` // JSON/YAML key from json tag + Type string `json:"type"` // Field type: string, int, bool, duration, etc. + Default string `json:"default"` // Default value from `d` tag + Rule string `json:"rule"` // Validation rule from `v` tag + Description string `json:"description"` // English description from `dc` tag + I18nKey string `json:"i18nKey"` // I18n key extracted from `dc` tag (i18n:xxx) + Group string `json:"group"` // Logical group (Basic, Logging, Cookie, etc.) + Options []string `json:"options,omitempty"` // Enum options if applicable } // ModuleSchema describes the configuration schema for one module. diff --git a/os/gcfg/gcfg_z_unit_schema_test.go b/os/gcfg/gcfg_z_unit_schema_test.go index 7c9fb86a3..4658dae00 100644 --- a/os/gcfg/gcfg_z_unit_schema_test.go +++ b/os/gcfg/gcfg_z_unit_schema_test.go @@ -16,11 +16,11 @@ import ( // testServerConfig is a simplified version of ghttp.ServerConfig for testing. type testServerConfig struct { - Name string `json:"name" d:"default" v:"required" dc:"Server name|i18n:config.server.name"` - Address string `json:"address" d:":0" v:"required" dc:"Server listening address|i18n:config.server.address"` - ReadTimeout time.Duration `json:"readTimeout" d:"60s" dc:"HTTP read timeout|i18n:config.server.readTimeout"` - KeepAlive bool `json:"keepAlive" d:"true" dc:"Enable HTTP keep-alive"` - unexported string // should be skipped + Name string `json:"name" d:"default" v:"required" dc:"Server name|i18n:config.server.name"` + Address string `json:"address" d:":0" v:"required" dc:"Server listening address|i18n:config.server.address"` + ReadTimeout time.Duration `json:"readTimeout" d:"60s" dc:"HTTP read timeout|i18n:config.server.readTimeout"` + KeepAlive bool `json:"keepAlive" d:"true" dc:"Enable HTTP keep-alive"` + unexported string // should be skipped } // TestBaseConfig tests embedded struct scanning. @@ -30,9 +30,9 @@ type TestBaseConfig struct { } type TestDatabaseConfig struct { - TestBaseConfig // embedded - User string `json:"user" d:"root" v:"required" dc:"Database user|i18n:config.database.user"` - Password string `json:"password" v:"required" dc:"Database password|i18n:config.database.password"` + TestBaseConfig // embedded + User string `json:"user" d:"root" v:"required" dc:"Database user|i18n:config.database.user"` + Password string `json:"password" v:"required" dc:"Database password|i18n:config.database.password"` } func TestSchemaRegistry_Register(t *testing.T) { diff --git a/os/glog/glog_logger_config.go b/os/glog/glog_logger_config.go index 629b78e46..a758c6964 100644 --- a/os/glog/glog_logger_config.go +++ b/os/glog/glog_logger_config.go @@ -23,30 +23,30 @@ import ( // Config is the configuration object for logger. type Config struct { - Handlers []Handler `json:"-"` // Logger handlers which implement feature similar as middleware. - Writer io.Writer `json:"-"` // Customized io.Writer. - Flags int `json:"flags" d:"20" dc:"Extra flags for logging output|i18n:config.logger.flags"` // Extra flags for logging output features. - TimeFormat string `json:"timeFormat" d:"2006-01-02T15:04:05.000Z07:00" dc:"Logging time format|i18n:config.logger.timeFormat"` // Logging time format - Path string `json:"path" dc:"Logging directory path|i18n:config.logger.path"` // Logging directory path. - File string `json:"file" d:"{Y-m-d}.log" dc:"Log file name pattern|i18n:config.logger.file"` // Format pattern for logging file. - Level int `json:"level" d:"992" dc:"Output level (DEBU=16,INFO=32,NOTI=64,WARN=128,ERRO=256,CRIT=512,ALL=992)|i18n:config.logger.level"` // Output level. - Prefix string `json:"prefix" dc:"Prefix for logging content|i18n:config.logger.prefix"` // Prefix string for every logging content. - StSkip int `json:"stSkip" d:"0" dc:"Stack skip count|i18n:config.logger.stSkip"` // Skipping count for stack. - StStatus int `json:"stStatus" d:"1" dc:"Stack status (1=enabled, 0=disabled)|i18n:config.logger.stStatus"` // Stack status(1: enabled - default; 0: disabled) - StFilter string `json:"stFilter" dc:"Stack string filter|i18n:config.logger.stFilter"` // Stack string filter. - CtxKeys []any `json:"ctxKeys"` // Context keys for logging, which is used for value retrieving from context. - HeaderPrint bool `json:"header" d:"true" dc:"Print log header|i18n:config.logger.headerPrint"` // Print header or not(true in default). - StdoutPrint bool `json:"stdout" d:"true" dc:"Output to stdout|i18n:config.logger.stdoutPrint"` // Output to stdout or not(true in default). - LevelPrint bool `json:"levelPrint" d:"true" dc:"Print level string|i18n:config.logger.levelPrint"` // Print level format string or not(true in default). - LevelPrefixes map[int]string `json:"levelPrefixes"` // Logging level to its prefix string mapping. - RotateSize int64 `json:"rotateSize" d:"0" dc:"Rotate file size in bytes (0=disabled)|i18n:config.logger.rotateSize"` // Rotate the logging file if its size > 0 in bytes. - RotateExpire time.Duration `json:"rotateExpire" d:"0" dc:"Rotate file expire duration|i18n:config.logger.rotateExpire"` // Rotate the logging file if its mtime exceeds this duration. - RotateBackupLimit int `json:"rotateBackupLimit" d:"0" dc:"Max rotated backup files|i18n:config.logger.rotateBackupLimit"` // Max backup for rotated files, default is 0, means no backups. - RotateBackupExpire time.Duration `json:"rotateBackupExpire" d:"0" dc:"Rotated backup file expire|i18n:config.logger.rotateBackupExpire"` // Max expires for rotated files, which is 0 in default, means no expiration. - RotateBackupCompress int `json:"rotateBackupCompress" d:"0" dc:"Gzip compress level for backup|i18n:config.logger.rotateBackupCompress"` // Compress level for rotated files using gzip algorithm. It's 0 in default, means no compression. - RotateCheckInterval time.Duration `json:"rotateCheckInterval" d:"1h" dc:"Async rotate check interval|i18n:config.logger.rotateCheckInterval"` // Asynchronously checks the backups and expiration at intervals. It's 1 hour in default. - StdoutColorDisabled bool `json:"stdoutColorDisabled" d:"false" dc:"Disable stdout color|i18n:config.logger.stdoutColorDisabled"` // Logging level prefix with color to writer or not (false in default). - WriterColorEnable bool `json:"writerColorEnable" d:"false" dc:"Enable writer color|i18n:config.logger.writerColorEnable"` // Logging level prefix with color to writer or not (false in default). + Handlers []Handler `json:"-"` // Logger handlers which implement feature similar as middleware. + Writer io.Writer `json:"-"` // Customized io.Writer. + Flags int `json:"flags" d:"20" dc:"Extra flags for logging output|i18n:config.logger.flags"` // Extra flags for logging output features. + TimeFormat string `json:"timeFormat" d:"2006-01-02T15:04:05.000Z07:00" dc:"Logging time format|i18n:config.logger.timeFormat"` // Logging time format + Path string `json:"path" dc:"Logging directory path|i18n:config.logger.path"` // Logging directory path. + File string `json:"file" d:"{Y-m-d}.log" dc:"Log file name pattern|i18n:config.logger.file"` // Format pattern for logging file. + Level int `json:"level" d:"992" dc:"Output level (DEBU=16,INFO=32,NOTI=64,WARN=128,ERRO=256,CRIT=512,ALL=992)|i18n:config.logger.level"` // Output level. + Prefix string `json:"prefix" dc:"Prefix for logging content|i18n:config.logger.prefix"` // Prefix string for every logging content. + StSkip int `json:"stSkip" d:"0" dc:"Stack skip count|i18n:config.logger.stSkip"` // Skipping count for stack. + StStatus int `json:"stStatus" d:"1" dc:"Stack status (1=enabled, 0=disabled)|i18n:config.logger.stStatus"` // Stack status(1: enabled - default; 0: disabled) + StFilter string `json:"stFilter" dc:"Stack string filter|i18n:config.logger.stFilter"` // Stack string filter. + CtxKeys []any `json:"ctxKeys"` // Context keys for logging, which is used for value retrieving from context. + HeaderPrint bool `json:"header" d:"true" dc:"Print log header|i18n:config.logger.headerPrint"` // Print header or not(true in default). + StdoutPrint bool `json:"stdout" d:"true" dc:"Output to stdout|i18n:config.logger.stdoutPrint"` // Output to stdout or not(true in default). + LevelPrint bool `json:"levelPrint" d:"true" dc:"Print level string|i18n:config.logger.levelPrint"` // Print level format string or not(true in default). + LevelPrefixes map[int]string `json:"levelPrefixes"` // Logging level to its prefix string mapping. + RotateSize int64 `json:"rotateSize" d:"0" dc:"Rotate file size in bytes (0=disabled)|i18n:config.logger.rotateSize"` // Rotate the logging file if its size > 0 in bytes. + RotateExpire time.Duration `json:"rotateExpire" d:"0" dc:"Rotate file expire duration|i18n:config.logger.rotateExpire"` // Rotate the logging file if its mtime exceeds this duration. + RotateBackupLimit int `json:"rotateBackupLimit" d:"0" dc:"Max rotated backup files|i18n:config.logger.rotateBackupLimit"` // Max backup for rotated files, default is 0, means no backups. + RotateBackupExpire time.Duration `json:"rotateBackupExpire" d:"0" dc:"Rotated backup file expire|i18n:config.logger.rotateBackupExpire"` // Max expires for rotated files, which is 0 in default, means no expiration. + RotateBackupCompress int `json:"rotateBackupCompress" d:"0" dc:"Gzip compress level for backup|i18n:config.logger.rotateBackupCompress"` // Compress level for rotated files using gzip algorithm. It's 0 in default, means no compression. + RotateCheckInterval time.Duration `json:"rotateCheckInterval" d:"1h" dc:"Async rotate check interval|i18n:config.logger.rotateCheckInterval"` // Asynchronously checks the backups and expiration at intervals. It's 1 hour in default. + StdoutColorDisabled bool `json:"stdoutColorDisabled" d:"false" dc:"Disable stdout color|i18n:config.logger.stdoutColorDisabled"` // Logging level prefix with color to writer or not (false in default). + WriterColorEnable bool `json:"writerColorEnable" d:"false" dc:"Enable writer color|i18n:config.logger.writerColorEnable"` // Logging level prefix with color to writer or not (false in default). internalConfig } diff --git a/os/gview/gview_config.go b/os/gview/gview_config.go index f4e4e8ee5..ab7d9d95c 100644 --- a/os/gview/gview_config.go +++ b/os/gview/gview_config.go @@ -23,12 +23,12 @@ import ( // Config is the configuration object for template engine. type Config struct { - Paths []string `json:"paths" dc:"Template search paths|i18n:config.viewer.paths"` // Searching array for path, NOT concurrent-safe for performance purpose. - Data map[string]any `json:"data" dc:"Global template variables|i18n:config.viewer.data"` // Global template variables including configuration. - DefaultFile string `json:"defaultFile" d:"index.html" dc:"Default template file|i18n:config.viewer.defaultFile"` // Default template file for parsing. - Delimiters []string `json:"delimiters" dc:"Template delimiters|i18n:config.viewer.delimiters"` // Custom template delimiters. - AutoEncode bool `json:"autoEncode" d:"false" dc:"Auto HTML encode for XSS safety|i18n:config.viewer.autoEncode"` // Automatically encodes and provides safe html output, which is good for avoiding XSS. - I18nManager *gi18n.Manager `json:"-"` // I18n manager for the view. + Paths []string `json:"paths" dc:"Template search paths|i18n:config.viewer.paths"` // Searching array for path, NOT concurrent-safe for performance purpose. + Data map[string]any `json:"data" dc:"Global template variables|i18n:config.viewer.data"` // Global template variables including configuration. + DefaultFile string `json:"defaultFile" d:"index.html" dc:"Default template file|i18n:config.viewer.defaultFile"` // Default template file for parsing. + Delimiters []string `json:"delimiters" dc:"Template delimiters|i18n:config.viewer.delimiters"` // Custom template delimiters. + AutoEncode bool `json:"autoEncode" d:"false" dc:"Auto HTML encode for XSS safety|i18n:config.viewer.autoEncode"` // Automatically encodes and provides safe html output, which is good for avoiding XSS. + I18nManager *gi18n.Manager `json:"-"` // I18n manager for the view. } const (