switch to iterators and client polling
Publish / release (push) Failing after 17m20s

This commit is contained in:
2026-06-22 22:20:32 -04:00
parent 24fe4258f7
commit f174c2922c
7 changed files with 154 additions and 143 deletions
+18 -9
View File
@@ -1,6 +1,8 @@
package readsb
import (
"iter"
"slices"
"strings"
"time"
)
@@ -9,19 +11,26 @@ import (
// an aircraft is kept only if every filter passes (logical AND).
type AircraftFilter func(*Aircraft) bool
// Filter returns the aircraft that satisfy all of the supplied filters. With no
// filters it returns every aircraft. The receiver report is never mutated.
// All yields each aircraft that satisfies every supplied filter, lazily and in
// order. With no filters it yields every aircraft. Ranging may break early; the
// receiver report is never mutated.
func (r *AircraftReport) All(filters ...AircraftFilter) iter.Seq[Aircraft] {
return func(yield func(Aircraft) bool) {
for i := range r.Aircraft {
if keep(&r.Aircraft[i], filters) && !yield(r.Aircraft[i]) {
return
}
}
}
}
// Filter is the eager form of All: it collects the matching aircraft into a
// slice. With no filters it returns the report's own slice without copying.
func (r *AircraftReport) Filter(filters ...AircraftFilter) []Aircraft {
if len(filters) == 0 {
return r.Aircraft
}
out := make([]Aircraft, 0, len(r.Aircraft))
for i := range r.Aircraft {
if keep(&r.Aircraft[i], filters) {
out = append(out, r.Aircraft[i])
}
}
return out
return slices.Collect(r.All(filters...))
}
func keep(a *Aircraft, filters []AircraftFilter) bool {