Files
backend/configs/config.yaml
lafay 176cd20847
Some checks failed
Build Backend / build-docker (push) Has been cancelled
Build Backend / build (push) Has been cancelled
refactor: remove Gorse integration and implement HotRank feature
- Removed Gorse-related configurations, handlers, and dependencies from the codebase.
- Introduced HotRank feature with configuration options for ranking posts based on recent activity.
- Updated application structure to support HotRank processing, including new caching mechanisms and database interactions.
- Cleaned up related DTOs and repository methods to reflect the removal of Gorse and the addition of HotRank functionality.
2026-03-24 05:18:30 +08:00

247 lines
6.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 服务器配置
# 环境变量: APP_SERVER_HOST, APP_SERVER_PORT, APP_SERVER_MODE
server:
host: 0.0.0.0
port: 8080
mode: debug
# 数据库配置
# 环境变量:
# SQLite: APP_DATABASE_SQLITE_PATH
# Postgres: APP_DATABASE_POSTGRES_HOST, APP_DATABASE_POSTGRES_PORT, APP_DATABASE_POSTGRES_USER,
# APP_DATABASE_POSTGRES_PASSWORD, APP_DATABASE_POSTGRES_DBNAME
database:
type: sqlite # sqlite 或 postgres
sqlite:
path: ./data/carrot_bbs.db
postgres:
host: localhost
port: 5432
user: postgres
password: postgres
dbname: carrot_bbs
sslmode: disable
max_idle_conns: 10
max_open_conns: 100
log_level: warn
slow_threshold_ms: 200
ignore_record_not_found: true
parameterized_queries: true
# Redis配置
# 环境变量:
# 类型: APP_REDIS_TYPE (miniredis/redis)
# Redis: APP_REDIS_REDIS_HOST, APP_REDIS_REDIS_PORT, APP_REDIS_REDIS_PASSWORD, APP_REDIS_REDIS_DB
# Miniredis: APP_REDIS_MINIREDIS_HOST, APP_REDIS_MINIREDIS_PORT
redis:
type: miniredis # miniredis 或 redis
redis:
host: 1Panel-redis-dfmM
port: 6379
password: "redis_j8CMza"
db: 0
miniredis:
host: localhost
port: 6379
pool_size: 10
# 缓存配置
# 环境变量:
# APP_CACHE_ENABLED, APP_CACHE_KEY_PREFIX, APP_CACHE_DEFAULT_TTL, APP_CACHE_NULL_TTL
# APP_CACHE_JITTER_RATIO, APP_CACHE_DISABLE_FLUSHDB
# APP_CACHE_MODULES_POST_LIST_TTL, APP_CACHE_MODULES_CONVERSATION_TTL
# APP_CACHE_MODULES_UNREAD_COUNT_TTL, APP_CACHE_MODULES_GROUP_MEMBERS_TTL
cache:
enabled: true
key_prefix: ""
default_ttl: 30
null_ttl: 5
jitter_ratio: 0.1
disable_flushdb: true
modules:
post_list_ttl: 30
conversation_ttl: 60
unread_count_ttl: 30
group_members_ttl: 120
# 热门榜:定时在「候选池」上重算,只写入 Redis ZSETTopN+ top_ids供本地缓存不写数据库
hot_rank:
enabled: true
refresh_interval_seconds: 300
top_n: 100
recent_window_hours: 168 # 7 天内新帖进入候选
recent_fetch_limit: 500
candidate_cap: 800 # 上届 Top + 新帖 ID 合并后上限
# S3对象存储配置
# 环境变量: APP_S3_ENDPOINT, APP_S3_ACCESS_KEY, APP_S3_SECRET_KEY, APP_S3_BUCKET, APP_S3_DOMAIN
s3:
endpoint: "files.littlelan.cn"
access_key: "E6bMcYkQzCldRTrtmhvi"
secret_key: "4R9yjmwKNoHphiBkv05Oa8WGEIFbnlZeTLXfSgx3"
bucket: "test"
use_ssl: true
region: us-east-1
domain: "files.littlelan.cn"
# JWT配置
# 环境变量: APP_JWT_SECRET
jwt:
secret: your-jwt-secret-key-change-in-production
access_token_expire: 86400 # 24 hours in seconds
refresh_token_expire: 604800 # 7 days in seconds
log:
level: info
encoding: json
output_paths:
- stdout
- ./logs/app.log
retention:
access_log: 180 # HTTP访问日志 6个月
operation_log: 365 # 操作日志 1年
login_log: 1095 # 登录日志 3年
data_change: 1095 # 数据变更日志 3年
async:
buffer_size: 10000
batch_size: 100
flush_interval: 3s
worker_count: 3
enable_fallback: true
fallback_path: ./logs/fallback.log
sensitive:
enabled: true
mask_fields:
- password
- token
- secret
- phone
- id_card
- bank_card
rotation:
max_size: 100
max_age: 30
max_backups: 10
compress: true
rate_limit:
enabled: true
requests_per_minute: 60
upload:
max_file_size: 10485760 # 10MB
allowed_types:
- image/jpeg
- image/png
- image/gif
- image/webp
# 敏感词过滤配置
sensitive:
enabled: true
replace_str: "***"
min_match_len: 1
load_from_db: true
load_from_redis: false
redis_key_prefix: "sensitive_words"
# 内容审核服务配置
audit:
enabled: false # 暂时关闭第三方审核
# 审核服务提供商: local, aliyun, tencent, baidu
provider: "local"
auto_audit: true
timeout: 30
# 阿里云配置
aliyun_access_key: ""
aliyun_secret_key: ""
aliyun_region: "cn-shanghai"
# 腾讯云配置
tencent_secret_id: ""
tencent_secret_key: ""
# 百度云配置
baidu_api_key: ""
baidu_secret_key: ""
# OpenAI兼容接口配置用于帖子审核支持图文
# 环境变量:
# APP_OPENAI_ENABLED, APP_OPENAI_BASE_URL, APP_OPENAI_API_KEY
# APP_OPENAI_MODERATION_MODEL, APP_OPENAI_MODERATION_MAX_IMAGES_PER_REQUEST
# APP_OPENAI_REQUEST_TIMEOUT, APP_OPENAI_STRICT_MODERATION
openai:
enabled: true
base_url: "https://api.littlelan.cn/"
api_key: "sk-y7LOeKsNfzbZWTRSFsTs79jd8WYlezbIVgdVPgMvG4Xz2AlV"
moderation_model: "qwen3.5-122b"
moderation_max_images_per_request: 1
request_timeout: 30
strict_moderation: false
# SMTP发信配置gomail.v2
# 环境变量:
# APP_EMAIL_ENABLED, APP_EMAIL_HOST, APP_EMAIL_PORT
# APP_EMAIL_USERNAME, APP_EMAIL_PASSWORD
# APP_EMAIL_FROM_ADDRESS, APP_EMAIL_FROM_NAME
# APP_EMAIL_USE_TLS, APP_EMAIL_INSECURE_SKIP_VERIFY, APP_EMAIL_TIMEOUT
email:
enabled: true
host: "smtp.exmail.qq.com"
port: 465
username: "no-reply@qczlit.cn"
password: "HbvwwVjRyiWg9gsK"
from_address: "no-reply@qczlit.cn"
from_name: "Carrot BBS"
use_tls: true
insecure_skip_verify: false
timeout: 15
# 会话缓存配置
conversation_cache:
# TTL 配置
detail_ttl: 5m # 会话详情缓存时间
list_ttl: 60s # 会话列表缓存时间
participant_ttl: 5m # 参与者缓存时间
unread_ttl: 30s # 未读数缓存时间
# 消息缓存配置
message_detail_ttl: 30m # 单条消息详情缓存
message_list_ttl: 5m # 消息分页列表缓存
message_index_ttl: 30m # 消息索引缓存
message_count_ttl: 30m # 消息计数缓存
# 批量写入配置
batch_interval: 5s # 写入间隔
batch_threshold: 100 # 条数阈值
batch_max_size: 500 # 单次最大批量
buffer_max_size: 10000 # 写缓冲最大条数
# gRPC 服务器配置
# 环境变量:
# APP_GRPC_ENABLED, APP_GRPC_PORT
# APP_GRPC_TLS_ENABLED, APP_GRPC_TLS_CERT_FILE, APP_GRPC_TLS_KEY_FILE
grpc:
enabled: true
port: 50051
tls_enabled: false
tls_cert_file: ""
tls_key_file: ""
# Casbin RBAC权限系统配置
# 环境变量:
# APP_CASBIN_MODEL_PATH, APP_CASBIN_AUTO_SAVE, APP_CASBIN_AUTO_LOAD
# APP_CASBIN_ENABLE_CACHE, APP_CASBIN_CACHE_TTL
casbin:
model_path: "./configs/casbin/model.conf"
auto_save: true
auto_load: true
enable_cache: true
cache_ttl: 300
skip_routes:
- /health
- /api/v1/auth/login
- /api/v1/auth/register
- /api/v1/auth/check-username
- /api/v1/auth/password/send-code
- /api/v1/auth/password/reset
- /api/v1/auth/refresh
- /api/v1/admin/setup-super-admin