Remove concurrency config
Inference engines handle this now.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
concurrency: 1
|
|
||||||
shutdown_timeout: 30s
|
shutdown_timeout: 30s
|
||||||
|
|
||||||
server:
|
server:
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ type Config struct {
|
|||||||
// Address is the host:port to listen on.
|
// Address is the host:port to listen on.
|
||||||
Address string `yaml:"address"`
|
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.
|
// ShutdownTimeout is the maximum time to wait for graceful shutdown.
|
||||||
// Defaults to "30s".
|
// Defaults to "30s".
|
||||||
ShutdownTimeout string `yaml:"shutdown_timeout"`
|
ShutdownTimeout string `yaml:"shutdown_timeout"`
|
||||||
@@ -42,9 +39,6 @@ type Config struct {
|
|||||||
// ApplyDefaults sets default values for optional configuration fields.
|
// ApplyDefaults sets default values for optional configuration fields.
|
||||||
// Called automatically by Load before validation.
|
// Called automatically by Load before validation.
|
||||||
func (cfg *Config) ApplyDefaults() {
|
func (cfg *Config) ApplyDefaults() {
|
||||||
if cfg.Concurrency == 0 {
|
|
||||||
cfg.Concurrency = 1
|
|
||||||
}
|
|
||||||
if cfg.ShutdownTimeout == "" {
|
if cfg.ShutdownTimeout == "" {
|
||||||
cfg.ShutdownTimeout = "30s"
|
cfg.ShutdownTimeout = "30s"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
func validConfig() string {
|
func validConfig() string {
|
||||||
return `
|
return `
|
||||||
address: ":9090"
|
address: ":9090"
|
||||||
concurrency: 2
|
|
||||||
shutdown_timeout: "60s"
|
shutdown_timeout: "60s"
|
||||||
|
|
||||||
llm:
|
llm:
|
||||||
@@ -55,12 +54,6 @@ func TestLoad(t *testing.T) {
|
|||||||
cfg.Address, ":9090",
|
cfg.Address, ":9090",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if cfg.Concurrency != 2 {
|
|
||||||
t.Errorf(
|
|
||||||
"Concurrency = %d, want 2",
|
|
||||||
cfg.Concurrency,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if cfg.ShutdownTimeout != "60s" {
|
if cfg.ShutdownTimeout != "60s" {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"ShutdownTimeout = %q, want %q",
|
"ShutdownTimeout = %q, want %q",
|
||||||
@@ -96,12 +89,6 @@ tts:
|
|||||||
cfg.Address, ":8080",
|
cfg.Address, ":8080",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if cfg.Concurrency != 1 {
|
|
||||||
t.Errorf(
|
|
||||||
"Concurrency = %d, want 1",
|
|
||||||
cfg.Concurrency,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if cfg.ShutdownTimeout != "30s" {
|
if cfg.ShutdownTimeout != "30s" {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"ShutdownTimeout = %q, want %q",
|
"ShutdownTimeout = %q, want %q",
|
||||||
@@ -365,9 +352,6 @@ func TestApplyDefaults(t *testing.T) {
|
|||||||
if cfg.Address != ":8080" {
|
if cfg.Address != ":8080" {
|
||||||
t.Errorf("Address = %q, want %q", 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" {
|
if cfg.ShutdownTimeout != "30s" {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"ShutdownTimeout = %q, want %q",
|
"ShutdownTimeout = %q, want %q",
|
||||||
@@ -379,7 +363,6 @@ func TestApplyDefaults(t *testing.T) {
|
|||||||
func TestApplyDefaults_NoOverwrite(t *testing.T) {
|
func TestApplyDefaults_NoOverwrite(t *testing.T) {
|
||||||
cfg := &Config{
|
cfg := &Config{
|
||||||
Address: ":9999",
|
Address: ":9999",
|
||||||
Concurrency: 5,
|
|
||||||
ShutdownTimeout: "120s",
|
ShutdownTimeout: "120s",
|
||||||
}
|
}
|
||||||
cfg.ApplyDefaults()
|
cfg.ApplyDefaults()
|
||||||
@@ -387,9 +370,6 @@ func TestApplyDefaults_NoOverwrite(t *testing.T) {
|
|||||||
if cfg.Address != ":9999" {
|
if cfg.Address != ":9999" {
|
||||||
t.Errorf("Address = %q, want %q", 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" {
|
if cfg.ShutdownTimeout != "120s" {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"ShutdownTimeout = %q, want %q",
|
"ShutdownTimeout = %q, want %q",
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
openai "github.com/sashabaranov/go-openai"
|
openai "github.com/sashabaranov/go-openai"
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed all:static/*
|
//go:embed all:static/*
|
||||||
@@ -42,7 +41,6 @@ type Service struct {
|
|||||||
llm *llm.Client
|
llm *llm.Client
|
||||||
log *slog.Logger
|
log *slog.Logger
|
||||||
mux *http.ServeMux
|
mux *http.ServeMux
|
||||||
sem *semaphore.Weighted
|
|
||||||
server *http.Server
|
server *http.Server
|
||||||
stt *stt.Client
|
stt *stt.Client
|
||||||
tmpl *template.Template
|
tmpl *template.Template
|
||||||
@@ -57,7 +55,6 @@ func New(cfg *config.Config, log *slog.Logger) (*Service, error) {
|
|||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
log: log,
|
log: log,
|
||||||
mux: http.NewServeMux(),
|
mux: http.NewServeMux(),
|
||||||
sem: semaphore.NewWeighted(int64(cfg.Concurrency)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup tool registry.
|
// 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 {
|
func (svc *Service) Run(ctx context.Context) error {
|
||||||
svc.log.Info(
|
svc.log.Info(
|
||||||
"starting odidere",
|
"starting odidere",
|
||||||
slog.Int("concurrency", svc.cfg.Concurrency),
|
|
||||||
slog.Group(
|
slog.Group(
|
||||||
"llm",
|
"llm",
|
||||||
slog.String("url", svc.cfg.LLM.URL),
|
slog.String("url", svc.cfg.LLM.URL),
|
||||||
@@ -582,17 +578,6 @@ func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
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 (
|
var (
|
||||||
messages = req.Messages
|
messages = req.Messages
|
||||||
transcription string
|
transcription string
|
||||||
|
|||||||
Reference in New Issue
Block a user