Add timestamp to pool events.

This commit is contained in:
Jay
2026-05-06 15:23:30 -04:00
parent efdbf7b37f
commit c87a8cce6f
5 changed files with 9 additions and 5 deletions
+2
View File
@@ -8,6 +8,7 @@ import (
"log/slog"
"sync"
"sync/atomic"
"time"
)
// Types
@@ -22,6 +23,7 @@ const (
type PoolEvent struct {
ID string
Kind PoolEventKind
At time.Time
}
type PoolStats struct {
+1 -1
View File
@@ -36,7 +36,7 @@ func expectEvent(
honeybeetest.Eventually(t, func() bool {
select {
case e := <-events:
return e.ID == expectedURL && e.Kind == expectedKind
return e.ID == expectedURL && e.Kind == expectedKind && !e.At.IsZero()
default:
return false
}
+2 -2
View File
@@ -261,7 +261,7 @@ func (s *Session) Start(
// set up new connection
s.connPtr.Store(conn)
pool.Events <- PoolEvent{ID: s.id, Kind: EventConnected}
pool.Events <- PoolEvent{ID: s.id, Kind: EventConnected, At: time.Now()}
// set up session context
sctx, scancel := context.WithCancel(ctx)
@@ -296,7 +296,7 @@ func (s *Session) Start(
// tear down connection
s.connPtr.Store(nil)
pool.Events <- PoolEvent{ID: s.id, Kind: EventDisconnected}
pool.Events <- PoolEvent{ID: s.id, Kind: EventDisconnected, At: time.Now()}
// exit if worker is shutting down
select {