Documentation
¶
Overview ¶
Package ticker emits the ephemeral announcements that scroll across the site.
These are not the editorial announcements stored in the announcements table. They are transient: a titan died, a battle is happening, a war was declared. Nothing keeps them beyond their expiry, and nothing is lost if one is missed — the killmail is still on the site either way.
Each is published twice for that reason. The relay delivers it to whoever is already connected, and a short-lived Redis key holds it so a page loaded a minute later still sees it. Neither is authoritative and both are allowed to fail.
Index ¶
- Constants
- func FormatCount(n int) string
- func FormatISK(v float64) string
- func SlotGroup(flag int32) int32
- func WarEndedBody(aggressor, defender string, aggressorISK, defenderISK float64, retracted bool) string
- type Announcement
- type Emitter
- func (e *Emitter) BattleExpired(ctx context.Context, battleID int64)
- func (e *Emitter) BattleStarted(ctx context.Context, battleID int64, systemName, regionName string, kills int, ...)
- func (e *Emitter) Emit(ctx context.Context, s Spec)
- func (e *Emitter) EvaluateKillmail(ctx context.Context, p killmail.Parsed)
- func (e *Emitter) Expire(ctx context.Context, id int64)
- func (e *Emitter) TQOffline(ctx context.Context, detail string)
- func (e *Emitter) TQOnline(ctx context.Context, detail string)
- func (e *Emitter) WarEnded(ctx context.Context, warID int32, aggressor, defender string, ...)
- func (e *Emitter) WarStarted(ctx context.Context, warID int32, aggressor, defender string, ...)
- type Spec
Constants ¶
const ( GroupTitan int32 = 30 GroupSupercarrier int32 = 659 GroupCapsule int32 = 29 )
Hull groups worth announcing on their own.
const ( ThresholdHighValue = 25_000_000_000 ThresholdOfficerFit = 3_000_000_000 ThresholdExpensivePod = 10_000_000_000 )
Value thresholds, in ISK.
Set where they are because the ticker is a scarcity signal: lower them and it becomes a second killfeed that nobody reads.
const ( BattleIDBase int64 = -2_000_000_000 WarIDBase int64 = -3_000_000_000 // WarEndedOffset separates a war's end announcement from its start, which // would otherwise share an id and have the second overwrite the first. WarEndedOffset int64 = -500_000_000 )
Ephemeral ticker ids are negative so they can never collide with a real announcement row, and each category has its own band so the client can cap them independently:
kills -1 .. -1_999_999_999 (-killmail_id) battles -2_000_000_000 .. -2_999_999_999 (BattleIDBase - battle_id) wars -3_000_000_000 .. -3_999_999_999 (WarIDBase - war_id)
TQ status sits at -999_999_00X: inside the kill band, but far above any killmail id that will be issued in the game's lifetime.
const ( ColorInfo = "info" ColorWarning = "warning" ColorDanger = "danger" ColorSuccess = "success" )
Colors and icons, matching what the frontend knows how to render.
const MetaOfficer int32 = 5
MetaOfficer marks the rarest module tier. See inv_meta_groups.
Variables ¶
This section is empty.
Functions ¶
func FormatCount ¶
FormatCount renders an integer with thousands separators, matching the client's toLocaleString output.
func FormatISK ¶
FormatISK renders a value the way the ticker shows it: 1.2T, 340.5B, 900M.
Anything under a million keeps its digits — at that scale the exact number is short enough to read and rounding it to "0M" would say nothing.
func SlotGroup ¶
SlotGroup maps an inventory flag to its slot group: 1 high, 2 mid, 3 low, 4 rig, 5 subsystem, 6 drone bay. Zero for anything else.
Shared with the fittings extractor, which uses the same numbering.
func WarEndedBody ¶
func WarEndedBody(aggressor, defender string, aggressorISK, defenderISK float64, retracted bool) string
WarEndedBody summarises how a war went.
EVE declares no winner, so neither does this. The honest summary is who destroyed more ISK, and the two degenerate cases — a war with no fighting, and one too close to call — get their own wording rather than being forced into a victory narrative.
Types ¶
type Announcement ¶
type Announcement struct {
ID int64 `json:"id"`
Tier int `json:"tier"`
Title string `json:"title"`
BodyMD string `json:"body_md"`
BodyHTML string `json:"body_html"`
Color string `json:"color"`
Icon string `json:"icon"`
LinkURL *string `json:"link_url"`
LinkLabel *string `json:"link_label"`
StartsAt string `json:"starts_at"`
ExpiresAt string `json:"expires_at"`
CreatedAt string `json:"created_at"`
}
Announcement is the payload the frontend consumes.
The field names are a contract with the client, and BodyHTML duplicating BodyMD is deliberate: ticker text is plain, and the client renders whichever field its announcement component expects.
type Emitter ¶
Emitter publishes ticker announcements.
Both dependencies are optional. A CLI path that detects a battle without a relay should still detect the battle.
func (*Emitter) BattleExpired ¶
BattleExpired retracts a battle announcement.
The hourly re-detection deletes and re-inserts auto-detected battles, giving the same real fight a new id each time. Without this the ticker accumulates one entry per re-detection of a battle that has not changed.
func (*Emitter) BattleStarted ¶
func (e *Emitter) BattleStarted(ctx context.Context, battleID int64, systemName, regionName string, kills int, isk float64)
BattleStarted announces a detected battle.
func (*Emitter) Emit ¶
Emit publishes one announcement to the relay and to Redis.
Errors are swallowed on purpose. The caller has already stored a killmail or saved a battle; failing that work because a decoration did not go out would be the wrong trade.
func (*Emitter) EvaluateKillmail ¶
EvaluateKillmail emits at most one announcement for a killmail.
func (*Emitter) WarEnded ¶
func (e *Emitter) WarEnded(ctx context.Context, warID int32, aggressor, defender string, aggressorISK, defenderISK float64, retracted bool)
WarEnded announces a war ending.
func (*Emitter) WarStarted ¶
func (e *Emitter) WarStarted(ctx context.Context, warID int32, aggressor, defender string, mutual, openForAllies bool)
WarStarted announces a war going live.
Fires on the transition to live rather than on declaration: EVE wars have a 24-hour cooldown before anyone may shoot, and that moment is the one that matters to the people in it.