Files
Misaki 5be7f7f04b feat: implement AI schedule app with multi-device sync
- Qt 6 desktop client with day/month/year views, AI scheduling, and TOML settings\n- Go sync server with SQLite change stream, WebSocket notifications, and Docker deployment\n- Client outbox/LWW sync, offline retry, and dual-client integration tests\n- Linux fcitx5 setup, validation reports, and Windows MinGW preset
2026-10-26 13:58:45 +08:00

49 lines
841 B
Go

package config
import (
"os"
"strconv"
)
type Config struct {
ListenAddr string
DatabasePath string
TokenPepper string
MaxBatch int
}
func FromEnv() Config {
cfg := Config{
ListenAddr: getenv("SYNC_LISTEN_ADDR", ":8787"),
DatabasePath: getenv("SYNC_DB_PATH", "./data/sync.db"),
TokenPepper: os.Getenv("SYNC_TOKEN_PEPPER"),
MaxBatch: getenvInt("SYNC_MAX_BATCH", 500),
}
if cfg.MaxBatch < 1 {
cfg.MaxBatch = 500
}
if cfg.MaxBatch > 5000 {
cfg.MaxBatch = 5000
}
return cfg
}
func getenv(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}
func getenvInt(key string, fallback int) int {
value := os.Getenv(key)
if value == "" {
return fallback
}
parsed, err := strconv.Atoi(value)
if err != nil {
return fallback
}
return parsed
}