historydb

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 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 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.

type Series added in v1.3.2

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

Series is a fixed-size ring buffer of periodic samples: one slot per sampling interval covering the whole retention window, written in place and overwriting the oldest slot. Sizing the buffer to the retention makes expiry implicit — there is no sweep to run and no map to grow.

A sample may also carry "no data" (see RecordGap), which is served as a JSON null so the chart breaks its line instead of drawing a zero that would read as "the link was up and idle".

func NewSeries added in v1.3.2

func NewSeries(retention, interval time.Duration) *Series

NewSeries creates a series holding retention/interval samples. Both arguments must be positive; a buffer of at least one slot is always allocated.

func (*Series) Len added in v1.3.2

func (s *Series) Len() int

Len returns the number of samples currently held.

func (*Series) Record added in v1.3.2

func (s *Series) Record(value float64)

Record stores one sample taken now.

func (*Series) RecordGap added in v1.3.2

func (s *Series) RecordGap()

RecordGap stores a sample that carries no usable data — the source was unavailable for the window, or its counter went backwards. It keeps the series' timeline honest: the point exists, its value is unknown.

func (*Series) ToSlice added in v1.3.2

func (s *Series) ToSlice() [][2]any

ToSlice returns every sample held, oldest first.

func (*Series) ToSliceRange added in v1.3.2

func (s *Series) ToSliceRange(from, to float64) [][2]any

ToSliceRange returns the samples whose wall-clock timestamp falls within [from, to], oldest first; a zero bound leaves that side of the range open. Each entry is [unix seconds, value], with a nil value for a no-data sample.

The stored monotonic timestamps are converted to wall clock here, at read time, using the current offset between the two clocks — the same trick aprsc's counterdata module uses.

Jump to

Keyboard shortcuts

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