managarten/services/mana-crawler/internal/config/config.go
Till JS bf4d9cb9aa refactor(go-services): integrate shared-go into crawler + gateway, fix Dockerfiles
- mana-crawler: config → envutil, handler → httputil.WriteJSON
- mana-api-gateway: config → envutil, handlers → httputil.WriteJSON
- Fix Dockerfile COPY paths (remove stale -go suffix in all 4 services)
- All services now use packages/shared-go via replace directive

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 16:25:30 +01:00

44 lines
1.3 KiB
Go

package config
import (
"strconv"
"github.com/manacore/shared-go/envutil"
)
type Config struct {
Port int
DatabaseURL string
RedisHost string
RedisPort int
RedisPassword string
UserAgent string
DefaultRateLimit float64
DefaultMaxDepth int
DefaultMaxPages int
Timeout int // ms
Concurrency int
CORSOrigins []string
}
func Load() *Config {
rateLimit, _ := strconv.ParseFloat(envutil.Get("CRAWLER_DEFAULT_RATE_LIMIT", "2"), 64)
return &Config{
Port: envutil.GetInt("PORT", 3023),
DatabaseURL: envutil.Get("DATABASE_URL", "postgresql://manacore:devpassword@localhost:5432/manacore"),
RedisHost: envutil.Get("REDIS_HOST", "localhost"),
RedisPort: envutil.GetInt("REDIS_PORT", 6379),
RedisPassword: envutil.Get("REDIS_PASSWORD", ""),
UserAgent: envutil.Get("CRAWLER_USER_AGENT", "ManaCoreCrawler/1.0 (+https://manacore.io/bot)"),
DefaultRateLimit: rateLimit,
DefaultMaxDepth: envutil.GetInt("CRAWLER_DEFAULT_MAX_DEPTH", 3),
DefaultMaxPages: envutil.GetInt("CRAWLER_DEFAULT_MAX_PAGES", 100),
Timeout: envutil.GetInt("CRAWLER_TIMEOUT", 30000),
Concurrency: envutil.GetInt("QUEUE_CONCURRENCY", 5),
CORSOrigins: envutil.GetSlice("CORS_ORIGINS", []string{"http://localhost:3000", "http://localhost:5173"}),
}
}