Files
sponge/configs/serverNameExample.yml
2025-11-15 20:51:41 +08:00

168 lines
8.9 KiB
YAML

# If you need to convert YAML to a Go struct, please execute the command: make update-config
# app settings
app:
name: "serverNameExample" # server name
env: "dev" # runtime environment, dev: development environment, prod: production environment, test: test environment
version: "v0.0.0"
host: "127.0.0.1" # domain or ip, for service registration
enableStat: true # whether to turn on printing statistics, true:enable, false:disable
enableMetrics: true # whether to turn on indicator collection, true:enable, false:disable
enableHTTPProfile: false # whether to turn on performance analysis, true:enable, false:disable
enableLimit: false # whether to turn on rate limiting (adaptive), true:on, false:off
enableCircuitBreaker: false # whether to turn on circuit breaker(adaptive), true:on, false:off
enableTrace: false # whether to turn on trace, true:enable, false:disable, if true jaeger configuration must be set
tracingSamplingRate: 1.0 # tracing sampling rate, between 0 and 1, 0 means no sampling, 1 means sampling all links
registryDiscoveryType: "" # registry and discovery types: consul, etcd, nacos, if empty, registration and discovery are not used
cacheType: "" # cache type, if empty, the cache is not used, support for "memory" and "redis", if set to redis, must set redis configuration
# todo generate http or rpc server configuration here
# delete the templates code start
# http server settings
http:
port: 8080 # listen port
timeout: 0 # request timeout, unit(second), if 0 means not set, if greater than 0 means set timeout, if enableHTTPProfile is true, it needs to set 0 or greater than 60s
tls:
# TLS mode options:
# self-signed - Use localhost self-signed certificate
# encrypt - Use Let's Encrypt (requires domain & email)
# external - Use external certificates (requires certFile & keyFile)
enableMode: ""
domain: "" # Required if enableMode = encrypt
email: "" # Required if enableMode = encrypt
certFile: "" # Required if enableMode = external, absolute path of cert file
keyFile: "" # Required if enableMode = external, absolute path of key file
# grpc server settings
grpc:
port: 8282 # listen port
httpPort: 8283 # profile and metrics ports
enableToken: false # whether to enable server-side token authentication, default appID=grpc, appKey=123456
# serverSecure parameter setting
# if type="", it means no secure connection, no need to fill in any parameters
# if type="one-way", it means server-side certification, only the fields 'certFile' and 'keyFile' should be filled in
# if type="two-way", it means both client and server side certification, fill in all fields
serverSecure:
type: "" # secures type, "", "one-way", "two-way"
caFile: "" # ca certificate file, valid only in "two-way", absolute path
certFile: "" # server side cert file, absolute path
keyFile: "" # server side key file, absolute path
# grpc client-side settings, support for setting up multiple grpc clients.
grpcClient:
- name: "serverNameExample" # grpc service name, used for service discovery
host: "127.0.0.1" # grpc service address, used for direct connection
port: 8282 # grpc service port
timeout: 0 # request timeout, unit(second), if 0 means not set, if greater than 0 means set timeout, valid only for unary grpc type
registryDiscoveryType: "" # registration and discovery types: consul, etcd, nacos, if empty, connecting to server using host and port
# clientSecure parameter setting
# if type="", it means no secure connection, no need to fill in any parameters
# if type="one-way", it means server-side certification, only the fields 'serverName' and 'certFile' should be filled in
# if type="two-way", it means both client and server side certification, fill in all fields
clientSecure:
type: "" # secures type, "", "one-way", "two-way"
serverName: "" # server name, e.g. *.foo.com
caFile: "" # client side ca file, valid only in "two-way", absolute path
certFile: "" # client side cert file, absolute path, if secureType="one-way", fill in server side cert file here
keyFile: "" # client side key file, valid only in "two-way", absolute path
clientToken:
enable: false # whether to enable token authentication
appID: "" # app id
appKey: "" # app key
# delete the templates code end
# logger settings
logger:
level: "info" # output log levels debug, info, warn, error, default is debug
format: "console" # output format, console or json, default is console
isSave: false # false:output to terminal, true:output to file, default is false
#logFileConfig: # Effective when isSave=true
#filename: "out.log" # File name (default is out.log)
#maxSize: 20 # Maximum file size (MB, default is 10MB)
#maxBackups: 50 # Maximum number of old files to retain (default is 100)
#maxAge: 15 # Maximum number of days to retain old files (default is 30 days)
#isCompression: true # Whether to compress/archive old files (default is false)
# todo generate the database configuration here
# delete the templates code start
# database setting
database:
driver: "mysql" # database driver, currently support mysql, postgresql, sqlite
# mysql settings
mysql:
# dsn format, <username>:<password>@(<hostname>:<port>)/<db>?[k=v& ......]
dsn: "root:123456@(192.168.3.37:3306)/account?parseTime=true&loc=Local&charset=utf8mb4&collation=utf8mb4_general_ci"
enableLog: true # whether to turn on printing of all logs
maxIdleConns: 10 # set the maximum number of connections in the idle connection pool
maxOpenConns: 100 # set the maximum number of open database connections
connMaxLifetime: 10 # sets the maximum time for which the connection can be reused, in minutes
#slavesDsn: # sets slaves mysql dsn, array type
# - "your slave dsn 1"
# - "your slave dsn 2"
#mastersDsn: # sets masters mysql dsn, array type, non-required field, if there is only one master, there is no need to set the mastersDsn field, the default dsn field is mysql master.
# - "your master dsn"
# postgresql settings
postgresql:
# dsn format, <username>:<password>@<hostname>:<port>/<db>?[k=v& ......]
dsn: "root:123456@192.168.3.37:5432/account?sslmode=disable"
enableLog: true # whether to turn on printing of all logs
maxIdleConns: 10 # set the maximum number of connections in the idle connection pool
maxOpenConns: 100 # set the maximum number of open database connections
connMaxLifetime: 10 # sets the maximum time for which the connection can be reused, in minutes
# sqlite settings
sqlite:
dbFile: "test/sql/sqlite/sponge.db" # if you are in a Windows environment, the path separator is \\
enableLog: true # whether to turn on printing of all logs
maxIdleConns: 10 # set the maximum number of connections in the idle connection pool
maxOpenConns: 100 # set the maximum number of open database connections
connMaxLifetime: 10 # sets the maximum time for which the connection can be reused, in minutes
# mongodb settings
mongodb:
# dsn format, [scheme://]<username>:<password>@<hostname1>:<port1>[,<hostname2>:<port2>,......]/<db>?[k=v& ......]
# default scheme is mongodb://, scheme can be omitted, if you want to use ssl, you can use mongodb+srv:// scheme, the scheme must be filled in
# parameter k=v see https://www.mongodb.com/docs/drivers/go/current/fundamentals/connections/connection-guide/#connection-options
dsn: "root:123456@192.168.3.37:27017/account?connectTimeoutMS=15000"
# delete the templates code end
# redis settings
redis:
# dsn format, [user]:<pass>@127.0.0.1:6379/[db], the default user is default, redis version 6.0 and above only supports user.
dsn: "default:123456@192.168.3.37:6379/0"
dialTimeout: 10 # connection timeout, unit(second)
readTimeout: 2 # read timeout, unit(second)
writeTimeout: 2 # write timeout, unit(second)
# jaeger settings
jaeger:
agentHost: "192.168.3.37"
agentPort: 6831
# todo generate the registry and discovery configuration here
# delete the templates code start
# consul settings
consul:
addr: "192.168.3.37:8500"
# etcd settings
etcd:
addrs: ["192.168.3.37:2379"]
# nacos settings, used in service registration discovery
nacosRd:
ipAddr: "192.168.3.37"
port: 8848
namespaceID: "3454d2b5-2455-4d0e-bf6d-e033b086bb4c" # namespace id
# delete the templates code end