alt/services/worker/internal/config/config.go
toki 87c7f9cdee chore(ports): 워크스페이스 포트를 표준화한다
API/worker runtime default와 local infra host publish가 같은 포트 정책을 사용하도록 맞춘다.\n\nagent-task 리뷰 산출물을 함께 남겨 포트 표준화 작업의 검토 이력을 추적할 수 있게 한다.
2026-06-07 13:44:37 +09:00

47 lines
1 KiB
Go

package config
import (
"os"
"strconv"
)
type Config struct {
DatabaseURL string
RedisURL string
RedisKeyPrefix string
WorkerQueue string
Host string
Port int
SocketPath string
}
func Load() Config {
return Config{
DatabaseURL: getenv("DATABASE_URL", "postgres://alt:alt@localhost:15430/alt?sslmode=disable"),
RedisURL: getenv("REDIS_URL", "redis://localhost:16330/0"),
RedisKeyPrefix: getenv("ALT_REDIS_KEY_PREFIX", "alt"),
WorkerQueue: getenv("ALT_WORKER_QUEUE", "default"),
Host: getenv("ALT_WORKER_HOST", "127.0.0.1"),
Port: getenvInt("ALT_WORKER_PORT", 18031),
SocketPath: getenv("ALT_WORKER_SOCKET_PATH", "/socket"),
}
}
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
}