statuses update
This commit is contained in:
@@ -15,6 +15,7 @@ type Config struct {
|
||||
InputExchange string
|
||||
InputRoutingKey string
|
||||
Prefetch int
|
||||
StatusQueue string
|
||||
|
||||
NexaraBaseURL string
|
||||
NexaraAPIKey string
|
||||
@@ -38,6 +39,7 @@ func Load() Config {
|
||||
InputExchange: getEnv("RABBITMQ_EXCHANGE", "audio_pipeline"),
|
||||
InputRoutingKey: getEnv("RABBITMQ_ROUTING_KEY", "audio.new"),
|
||||
Prefetch: getInt("PREFETCH", 1),
|
||||
StatusQueue: getEnv("STATUS_QUEUE", "pipeline.status"),
|
||||
|
||||
NexaraBaseURL: getEnv("NEXARA_BASE_URL", "https://api.nexara.ru"),
|
||||
NexaraAPIKey: os.Getenv("NEXARA_API_KEY"),
|
||||
|
||||
51
workers/transcribe/internal/config/config_test.go
Normal file
51
workers/transcribe/internal/config/config_test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLoadDefaults(t *testing.T) {
|
||||
t.Setenv("RABBITMQ_URL", "")
|
||||
t.Setenv("STATUS_QUEUE", "")
|
||||
t.Setenv("NEXARA_TIMEOUT", "")
|
||||
|
||||
cfg := Load()
|
||||
if cfg.InputQueue != "transcribe.tasks" {
|
||||
t.Fatalf("InputQueue: got %q", cfg.InputQueue)
|
||||
}
|
||||
if cfg.StatusQueue != "pipeline.status" {
|
||||
t.Fatalf("StatusQueue: got %q", cfg.StatusQueue)
|
||||
}
|
||||
if cfg.NexaraTimeout != 10*time.Minute {
|
||||
t.Fatalf("NexaraTimeout: got %v", cfg.NexaraTimeout)
|
||||
}
|
||||
if cfg.PromptsSection != 1 {
|
||||
t.Fatalf("PromptsSection: got %d", cfg.PromptsSection)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromEnv(t *testing.T) {
|
||||
t.Setenv("INPUT_QUEUE", "custom.tasks")
|
||||
t.Setenv("STATUS_QUEUE", "status.events")
|
||||
t.Setenv("PREFETCH", "4")
|
||||
t.Setenv("NEXARA_TIMEOUT", "2m")
|
||||
t.Setenv("PROMPTS_SECTION", "2")
|
||||
|
||||
cfg := Load()
|
||||
if cfg.InputQueue != "custom.tasks" {
|
||||
t.Fatalf("InputQueue: got %q", cfg.InputQueue)
|
||||
}
|
||||
if cfg.StatusQueue != "status.events" {
|
||||
t.Fatalf("StatusQueue: got %q", cfg.StatusQueue)
|
||||
}
|
||||
if cfg.Prefetch != 4 {
|
||||
t.Fatalf("Prefetch: got %d", cfg.Prefetch)
|
||||
}
|
||||
if cfg.NexaraTimeout != 2*time.Minute {
|
||||
t.Fatalf("NexaraTimeout: got %v", cfg.NexaraTimeout)
|
||||
}
|
||||
if cfg.PromptsSection != 2 {
|
||||
t.Fatalf("PromptsSection: got %d", cfg.PromptsSection)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user