simplified enqueue

This commit is contained in:
pippellia-btc
2025-06-06 17:06:44 +02:00
parent c35711710f
commit 3d28ad1c5a

View File

@@ -111,15 +111,15 @@ func handleSignals(cancel context.CancelFunc) {
cancel()
}
// enqueue things into the specified channel or log if full
// enqueue things into the specified channel or return an error if full.
func enqueue[T any](queue chan T) func(t T) error {
return func(t T) error {
select {
case queue <- t:
default:
log.Printf("channel is full, dropping %v", t)
}
return nil
default:
return fmt.Errorf("channel is full, dropping %v", t)
}
}
}