Wrote worker tests.

This commit is contained in:
Jay
2026-04-20 09:26:19 -04:00
parent 9b29592a39
commit de3c997279
5 changed files with 399 additions and 3 deletions
+5 -2
View File
@@ -33,6 +33,9 @@ func RunReader(
// by default, the peer dropped unexpectedly
kind := EventPeerDropped
select {
// the peer-side error is sent before the connection is closed,
// so a non-blocking call here is correct
// if an error is not sent, then assume the default event kind
case err := <-conn.Errors():
if errors.Is(err, transport.ErrPeerClosedClean) {
kind = EventPeerDisconnected
@@ -101,7 +104,7 @@ func RunForwarder(
func RunWatchdog(
ctx context.Context,
onTimeout onEventFunc,
onInactive func(),
heartbeat <-chan struct{},
timeout time.Duration,
) {
@@ -133,7 +136,7 @@ func RunWatchdog(
// timer completed
case <-timer.C:
// signal peer is inactive
onTimeout(EventPeerInactive)
onInactive()
return
}
}