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
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user