fix: export chatd.Start to separate server lifecycle (#24761)

chatd.New() no longer auto-starts the acquire/wake loop.
Callers that want chat processing call server.Start()
explicitly. Tests that want a passive server skip Start();
heartbeat, stream janitor, and stale recovery still run.

Closes coder/internal#1502
This commit is contained in:
Mathias Fredriksson
2026-04-29 13:54:49 +03:00
committed by GitHub
parent f9068c2afa
commit dd49a818f9
5 changed files with 103 additions and 35 deletions
+5
View File
@@ -58,6 +58,7 @@ func newTestServer(
SubscribeFn: entchatd.NewMultiReplicaSubscribeFn(entchatd.MultiReplicaSubscribeConfig{DialerFn: dialer, Clock: clock}),
PendingChatAcquireInterval: testutil.WaitSuperLong,
})
server.Start()
t.Cleanup(func() {
require.NoError(t, server.Close())
})
@@ -80,6 +81,7 @@ func newActiveWorkerServer(
PendingChatAcquireInterval: 10 * time.Millisecond,
InFlightChatStaleAfter: testutil.WaitSuperLong,
})
server.Start()
t.Cleanup(func() {
require.NoError(t, server.Close())
})
@@ -1308,6 +1310,7 @@ func TestSubscribeRelayDialCanceledOnFastCompletion(t *testing.T) {
PendingChatAcquireInterval: time.Hour,
InFlightChatStaleAfter: testutil.WaitSuperLong,
})
worker.Start()
t.Cleanup(func() {
require.NoError(t, worker.Close())
})
@@ -1467,6 +1470,7 @@ func TestSubscribeRelayDrainWithinGraceLeavesBufferRetained(t *testing.T) {
InFlightChatStaleAfter: testutil.WaitSuperLong,
Clock: workerClock,
})
worker.Start()
t.Cleanup(func() {
require.NoError(t, worker.Close())
})
@@ -1662,6 +1666,7 @@ func TestSubscribeRelayEstablishedMidStream(t *testing.T) {
PendingChatAcquireInterval: time.Second,
InFlightChatStaleAfter: testutil.WaitSuperLong,
})
worker.Start()
t.Cleanup(func() {
require.NoError(t, worker.Close())
})