Help us shape the future of Go! Take the 2026 Go Developer Survey

historydb

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Positions = NewPositionHistory()

Positions is the process-wide station position store, shared by the packet ingestion path (which records positions) and the filter layer (which reads them for m/, f/ and ranged t/ filters).

Functions

This section is empty.

Types

type DupeChecker

type DupeChecker struct {
	// contains filtered or unexported fields
}

DupeChecker suppresses duplicate packets seen within a sliding time window. It is safe for concurrent use.

Duplicate detection is based on the packet's source callsign and information field only — the via path (and any q-construct appended to it) is ignored, so the same payload relayed through different paths is recognised as one packet. To also catch copies that a client has lightly corrupted in transit, each accepted packet is additionally stored under several normalised variants (trailing spaces removed, high bit handled, low/DEL bytes handled); a later packet matching any stored variant is treated as a duplicate.

func NewDupeChecker

func NewDupeChecker(window time.Duration) *DupeChecker

NewDupeChecker creates a checker that treats identical packets as duplicates if seen again within window.

func (*DupeChecker) Cleanup

func (d *DupeChecker) Cleanup()

Cleanup removes all entries older than the window. It is safe for concurrent use and intended to be called periodically (e.g. from cron) for long-lived checkers so the map does not retain expired keys indefinitely.

func (*DupeChecker) Seen

func (d *DupeChecker) Seen(packet string) bool

Seen reports whether packet was seen within the window; otherwise it records it (and its normalised variants) and returns false. Expired entries are pruned at most once per window (time-sampled) so the hot path stays O(1) amortised instead of scanning the whole map on every packet.

type HeardList

type HeardList struct {
	// contains filtered or unexported fields
}

HeardList records the set of source stations a client has recently received, each with a last-heard timestamp, expiring entries after a configurable TTL. It is safe for concurrent use.

func NewHeardList

func NewHeardList() *HeardList

NewHeardList creates an empty heard list with the default TTL.

func NewHeardListTTL

func NewHeardListTTL(ttl time.Duration) *HeardList

NewHeardListTTL creates an empty heard list whose entries expire after ttl. A non-positive ttl falls back to the default.

func (*HeardList) Add

func (h *HeardList) Add(call string)

Add records that the client has just heard the given station. Empty callsigns are ignored; growth is bounded by maxHeard.

func (*HeardList) Heard

func (h *HeardList) Heard(call string) bool

Heard reports whether the client has heard the given station within the TTL.

func (*HeardList) Len

func (h *HeardList) Len() int

Len returns the number of stations currently tracked (including any not yet expired-out).

func (*HeardList) Take

func (h *HeardList) Take(call string) bool

Take reports whether the given station is present and unexpired, removing it in that case so it matches at most once (one-shot consume). It is used to gate a single follow-up packet per recorded station.

type MapFloat64History

type MapFloat64History struct {
	D map[any]float64
	// contains filtered or unexported fields
}

MapFloat64History is the basic struct to record history with float64 map

func NewMapFloat64History

func NewMapFloat64History() *MapFloat64History

NewMapFloat64History creates a new history map with float64

func (*MapFloat64History) ClearByKey

func (d *MapFloat64History) ClearByKey(TTL float64)

ClearByKey clears expired data by key as time

func (*MapFloat64History) Record

func (d *MapFloat64History) Record(key any, value float64)

Record records data

func (*MapFloat64History) ToSlice

func (d *MapFloat64History) ToSlice() [][2]any

ToSlice transfers map to slice

func (*MapFloat64History) ToSliceRange added in v1.1.1

func (d *MapFloat64History) ToSliceRange(from, to float64) [][2]any

ToSliceRange transfers map to a timestamp-sorted slice. When from or to is zero, that side of the range is left open.

type PositionHistory

type PositionHistory struct {
	// contains filtered or unexported fields
}

PositionHistory records the last-known position of stations by callsign so position-aware filters can resolve friend/own positions. It is safe for concurrent use.

func NewPositionHistory

func NewPositionHistory() *PositionHistory

NewPositionHistory creates an empty position history store.

func (*PositionHistory) Cleanup

func (h *PositionHistory) Cleanup()

Cleanup removes expired entries. It is intended to be called periodically.

func (*PositionHistory) Get

func (h *PositionHistory) Get(call string) (lat, lon float64, ok bool)

Get returns the last-known position of a station. ok is false when the station is unknown or its record has expired.

func (*PositionHistory) Len

func (h *PositionHistory) Len() int

Len returns the number of currently stored stations (including any not yet expired-out by Cleanup).

func (*PositionHistory) Update

func (h *PositionHistory) Update(call string, lat, lon float64)

Update records (or refreshes) the position of a station. Calls with an empty callsign are ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL