- Add parser map for contract type resolution - Update socket handlers with new message routing - Add parser map tests - Remove outdated code review and plan docs for G07
44 lines
1 KiB
Go
44 lines
1 KiB
Go
package config
|
|
|
|
import "os"
|
|
|
|
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:5432/alt?sslmode=disable"),
|
|
RedisURL: getenv("REDIS_URL", "redis://localhost:6379/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", 8081),
|
|
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
|
|
}
|