diff --git a/config.example.yaml b/config.example.yaml index b9f0a81..87764cd 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -1,4 +1,3 @@ -concurrency: 1 shutdown_timeout: 30s server: diff --git a/internal/config/config.go b/internal/config/config.go index 044d5ef..826c50a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -20,9 +20,6 @@ type Config struct { // Address is the host:port to listen on. Address string `yaml:"address"` - // Concurrency is the number of concurrent requests to allow. - // Defaults to 1. - Concurrency int `yaml:"concurrency"` // ShutdownTimeout is the maximum time to wait for graceful shutdown. // Defaults to "30s". ShutdownTimeout string `yaml:"shutdown_timeout"` @@ -42,9 +39,6 @@ type Config struct { // ApplyDefaults sets default values for optional configuration fields. // Called automatically by Load before validation. func (cfg *Config) ApplyDefaults() { - if cfg.Concurrency == 0 { - cfg.Concurrency = 1 - } if cfg.ShutdownTimeout == "" { cfg.ShutdownTimeout = "30s" } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 21d2a88..f0367fe 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -11,7 +11,6 @@ import ( func validConfig() string { return ` address: ":9090" -concurrency: 2 shutdown_timeout: "60s" llm: @@ -55,12 +54,6 @@ func TestLoad(t *testing.T) { cfg.Address, ":9090", ) } - if cfg.Concurrency != 2 { - t.Errorf( - "Concurrency = %d, want 2", - cfg.Concurrency, - ) - } if cfg.ShutdownTimeout != "60s" { t.Errorf( "ShutdownTimeout = %q, want %q", @@ -96,12 +89,6 @@ tts: cfg.Address, ":8080", ) } - if cfg.Concurrency != 1 { - t.Errorf( - "Concurrency = %d, want 1", - cfg.Concurrency, - ) - } if cfg.ShutdownTimeout != "30s" { t.Errorf( "ShutdownTimeout = %q, want %q", @@ -365,9 +352,6 @@ func TestApplyDefaults(t *testing.T) { if cfg.Address != ":8080" { t.Errorf("Address = %q, want %q", cfg.Address, ":8080") } - if cfg.Concurrency != 1 { - t.Errorf("Concurrency = %d, want 1", cfg.Concurrency) - } if cfg.ShutdownTimeout != "30s" { t.Errorf( "ShutdownTimeout = %q, want %q", @@ -379,7 +363,6 @@ func TestApplyDefaults(t *testing.T) { func TestApplyDefaults_NoOverwrite(t *testing.T) { cfg := &Config{ Address: ":9999", - Concurrency: 5, ShutdownTimeout: "120s", } cfg.ApplyDefaults() @@ -387,9 +370,6 @@ func TestApplyDefaults_NoOverwrite(t *testing.T) { if cfg.Address != ":9999" { t.Errorf("Address = %q, want %q", cfg.Address, ":9999") } - if cfg.Concurrency != 5 { - t.Errorf("Concurrency = %d, want 5", cfg.Concurrency) - } if cfg.ShutdownTimeout != "120s" { t.Errorf( "ShutdownTimeout = %q, want %q", diff --git a/internal/service/service.go b/internal/service/service.go index eb68192..6acf622 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -29,7 +29,6 @@ import ( "github.com/google/uuid" openai "github.com/sashabaranov/go-openai" - "golang.org/x/sync/semaphore" ) //go:embed all:static/* @@ -42,7 +41,6 @@ type Service struct { llm *llm.Client log *slog.Logger mux *http.ServeMux - sem *semaphore.Weighted server *http.Server stt *stt.Client tmpl *template.Template @@ -57,7 +55,6 @@ func New(cfg *config.Config, log *slog.Logger) (*Service, error) { cfg: cfg, log: log, mux: http.NewServeMux(), - sem: semaphore.NewWeighted(int64(cfg.Concurrency)), } // Setup tool registry. @@ -193,7 +190,6 @@ func (svc *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (svc *Service) Run(ctx context.Context) error { svc.log.Info( "starting odidere", - slog.Int("concurrency", svc.cfg.Concurrency), slog.Group( "llm", slog.String("url", svc.cfg.LLM.URL), @@ -582,17 +578,6 @@ func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) { return } - // Acquire semaphore. - if err := svc.sem.Acquire(ctx, 1); err != nil { - http.Error( - w, - "service unavailable", - http.StatusServiceUnavailable, - ) - return - } - defer svc.sem.Release(1) - var ( messages = req.Messages transcription string