From 95dec85004a501344043e322272c1d4f7c135acf Mon Sep 17 00:00:00 2001 From: Shreesh Date: Mon, 2 Nov 2026 19:01:14 +0530 Subject: [PATCH 1/2] fix(config): read AC_REDIS_PASSWORD for a password-protected Redis --- README.md | 1 + cmd/stj-exec/main.go | 1 + internal/config/config.go | 14 ++++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 547481e..b116737 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ Configuration parameters are loaded from environment variables on startup. Refer | `AC_GATEWAY_ADDR` | `127.0.0.1:5100` | Gateway HTTP service listen address | | `AC_DATABASE_URL` | `postgres://aethercode:aethercode@127.0.0.1:5433/aethercode_exec` | PostgreSQL connection DSN | | `AC_REDIS_ADDR` | `127.0.0.1:6379` | Redis host address and port | +| `AC_REDIS_PASSWORD` | _(empty)_ | Redis password, when the server requires one | | `AC_JUDGE_URL` | `http://127.0.0.1:5050` | go-judge sandbox REST API endpoint | | `AC_JUDGE_TOKEN` | *(Required)* | Secret bearer token authenticating requests to go-judge | | `AC_WORKER_COUNT` | `8` | Total concurrent worker execution goroutines | diff --git a/cmd/stj-exec/main.go b/cmd/stj-exec/main.go index 48d3d5d..561d50e 100644 --- a/cmd/stj-exec/main.go +++ b/cmd/stj-exec/main.go @@ -89,6 +89,7 @@ func main() { // Redis rdb := redis.NewClient(&redis.Options{ Addr: cfg.RedisAddr, + Password: cfg.RedisPassword, PoolSize: cfg.RedisPool, MinIdleConns: cfg.RedisMinIdle, }) diff --git a/internal/config/config.go b/internal/config/config.go index 97e1937..bd55968 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,12 +12,13 @@ import ( ) type Config struct { - GatewayAddr string - DatabaseURL string - RedisAddr string - JudgeURL string - JudgeToken string - WorkerCount int + GatewayAddr string + DatabaseURL string + RedisAddr string + RedisPassword string + JudgeURL string + JudgeToken string + WorkerCount int // Connection pool sizes. The defaults suit up to about 128 concurrent // database users; ingest alone can use 512 at once (see the admission // semaphore), so raise DBMaxConns before raising ingest concurrency. @@ -86,6 +87,7 @@ func Load() Config { GatewayAddr: env("AC_GATEWAY_ADDR", "127.0.0.1:5100"), DatabaseURL: env("AC_DATABASE_URL", "postgres://aethercode:aethercode@127.0.0.1:5433/aethercode_exec"), RedisAddr: env("AC_REDIS_ADDR", "127.0.0.1:6379"), + RedisPassword: env("AC_REDIS_PASSWORD", ""), JudgeURL: env("AC_JUDGE_URL", "http://127.0.0.1:5050"), JudgeToken: env("AC_JUDGE_TOKEN", ""), WorkerCount: envInt("AC_WORKER_COUNT", 8), From 87fbff13c361c9c6319f9dcdc2c958c74c392076 Mon Sep 17 00:00:00 2001 From: Shreesh Date: Mon, 2 Nov 2026 19:46:42 +0530 Subject: [PATCH 2/2] test(queue): wait for the shared subscription before overflowing a slow client --- internal/queue/hub_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/queue/hub_test.go b/internal/queue/hub_test.go index 2e9580a..425f504 100644 --- a/internal/queue/hub_test.go +++ b/internal/queue/hub_test.go @@ -82,6 +82,12 @@ func TestHub_AClientThatFallsBehindIsClosedSoItReplays(t *testing.T) { defer cancel() slow := ps.Subscribe(ctx, "job-d") fast := ps.Subscribe(ctx, "job-e") + // The hub subscribes to Redis in the background: wait until it is live, or + // early events are lost and the buffer never overflows. + if err := ps.PublishEvent(ctx, eventlog.New("job-e", eventlog.EventRunning, nil)); err != nil { + t.Fatal(err) + } + recv(t, fast) for i := 0; i < subscriberBuffer+5; i++ { if err := ps.PublishEvent(ctx, eventlog.New("job-d", eventlog.EventRunning, nil)); err != nil {