Documentation
¶
Overview ¶
Package dataplan turns recorded per-network usage into "how much of my monthly data allowance is gone" — the number a tethered user would otherwise have to open their carrier's app to see. It is pure logic: billing-cycle arithmetic plus a quota status, with no I/O and no platform dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CycleEnd ¶
CycleEnd returns the exclusive end of the cycle containing now, i.e. the next cycle's start.
Types ¶
type Config ¶
type Config struct {
LimitBytes int64 `json:"limitBytes"` // monthly allowance in bytes (e.g. 100 GB)
StartDay int `json:"startDay"` // billing cycle start day-of-month, 1-31 (0 → 1)
Iface string `json:"iface"` // BSD name to meter; "" = every tethering network
// WarnPercent is the early-warning threshold; 0 uses 80. The 100% crossing
// always alerts regardless.
WarnPercent int `json:"warnPercent"`
}
Config is the user's metered-data plan. A zero LimitBytes disables everything.
type Status ¶
type Status struct {
Enabled bool `json:"enabled"`
LimitBytes int64 `json:"limitBytes"`
UsedBytes int64 `json:"usedBytes"`
RemainingBytes int64 `json:"remainingBytes"` // 0 once over the limit
Percent float64 `json:"percent"` // may exceed 100
CycleStart int64 `json:"cycleStart"` // unix seconds, local midnight
CycleEnd int64 `json:"cycleEnd"` // unix seconds, exclusive
DaysLeft int `json:"daysLeft"` // whole days until the cycle rolls over
// ProjectedBytes extrapolates the current daily average to the end of the
// cycle — "at this rate you'll finish at X". 0 when there's nothing to
// extrapolate from yet.
ProjectedBytes int64 `json:"projectedBytes"`
}
Status is a plan's state at a point in time — what the dashboard renders and what the alert checker compares against.
Click to show internal directories.
Click to hide internal directories.