Files

81 lines
2.0 KiB
Go
Raw Permalink Normal View History

2026-06-10 17:12:58 +03:00
package config
import (
"os"
"strconv"
"time"
)
type Config struct {
RabbitURL string
InputQueue string
OutputExchange string
AnalyseQueue string
TaggingQueue string
InputExchange string
InputRoutingKey string
Prefetch int
2026-06-24 18:58:35 +03:00
StatusQueue string
2026-06-10 17:12:58 +03:00
NexaraBaseURL string
NexaraAPIKey string
NexaraModel string
NexaraTimeout time.Duration
PromptsSource string
PromptsFile string
PromptsBaseURL string
PromptsAPIKey string
PromptsSection int
}
func Load() Config {
return Config{
RabbitURL: getEnv("RABBITMQ_URL", "amqp://guest:guest@localhost:5672/"),
InputQueue: getEnv("INPUT_QUEUE", "transcribe.tasks"),
OutputExchange: getEnv("OUTPUT_EXCHANGE", "transcription_done"),
AnalyseQueue: getEnv("ANALYSE_QUEUE", "analyse"),
TaggingQueue: getEnv("TAGGING_QUEUE", "tagging"),
InputExchange: getEnv("RABBITMQ_EXCHANGE", "audio_pipeline"),
InputRoutingKey: getEnv("RABBITMQ_ROUTING_KEY", "audio.new"),
Prefetch: getInt("PREFETCH", 1),
2026-06-24 18:58:35 +03:00
StatusQueue: getEnv("STATUS_QUEUE", "pipeline.status"),
2026-06-10 17:12:58 +03:00
NexaraBaseURL: getEnv("NEXARA_BASE_URL", "https://api.nexara.ru"),
NexaraAPIKey: os.Getenv("NEXARA_API_KEY"),
NexaraModel: getEnv("NEXARA_MODEL", "whisper-1"),
NexaraTimeout: getDuration("NEXARA_TIMEOUT", 10*time.Minute),
PromptsSource: getEnv("PROMPTS_SOURCE", "static"),
PromptsFile: getEnv("PROMPTS_FILE", "/app/configs/prompts.json"),
PromptsBaseURL: os.Getenv("PROMPTS_BASE_URL"),
PromptsAPIKey: os.Getenv("PROMPTS_API_KEY"),
PromptsSection: getInt("PROMPTS_SECTION", 1),
}
}
func getEnv(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}
func getInt(key string, def int) int {
if v := os.Getenv(key); v != "" {
if i, err := strconv.Atoi(v); err == nil {
return i
}
}
return def
}
func getDuration(key string, def time.Duration) time.Duration {
if v := os.Getenv(key); v != "" {
if d, err := time.ParseDuration(v); err == nil {
return d
}
}
return def
}